Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

Anchita Bose




Posted Answers



Answer


Enoxaparin is used to thin your blood It keeps your blood from forming clots Blood clots are dangerous because they can lead to serious blockages in your


Answer is posted for the following question.

What are the benefits of enoxaparin?

Answer


Check Following Video


Answer is posted for the following question.

How to set axonometric view in sketchup?

Answer


WordPress websites are also among the most vulnerable websites "inurl:"/wp-content/plugins/wp- shopping - cart /"


Answer is posted for the following question.

How to hack vulnerable shopping carts?

Answer


Boutique Sydney Salon located in the suburbs, offering a personalised and indulgent experience from Shop 5/187 Rocky Point Rd, Ramsgate , NSW,


Answer is posted for the following question.

How bizaar hair ramsgate?

Answer


Simply go to your Profile, and then select Set Online Status . Then just choose Appear Offline, and that's it. You'll see a red "X" next to your avatar to confirm that you're appearing offline to others.


Answer is posted for the following question.

How to hide ps4 online status?

Answer


A UNESCO World Heritage-listed site in the heart of historic Sydney, the Hyde Park Barracks is an extraordinary living record of early colonial Australia.


Answer is posted for the following question.

What is hyde park barracks?

Answer


Explains how to use the SELECT clause and projections in a JPA/JPQL query. If an entity class is used as a result class, the result entity objects are created in


Answer is posted for the following question.

How to create jpql query?

Answer


Though the general theme of the tattoo is depressing, k Michelle revealed her ink with a positive message. she says, “After every heartbreak, there will be sunshine .


Answer is posted for the following question.

What does k michelle tattoo say?

Answer


How has Saga's share price performed over time and what events caused price Stable Share Price: SAGA is more volatile than 75% of UK stocks over the past"Rating: 2/6 · Review by Simply Wall St


Answer is posted for the following question.

How are saga shares performing?

Answer


If you do, sometimes you will get an error message on the calculator screen when The TI-83 Plus requires that the argument of the square root be enclosed in


Answer is posted for the following question.

How to do square on graphing calculator?

Answer


Another great visit @ Dental One. Kudos to my dental hygienist Maxine for her being so good at what she d… Jeffrey K.. Every member of Dr


Answer is posted for the following question.

What is the best dentist in columbia md?

Answer


Iiyama ProLite E2473HDS-1 User Guide Manual USER MANUAL ENGLISH Thank you very much for choosing the iiyama LCD monitor. We recommend that you


Answer is posted for the following question.

How to reset iiyama monitor?

Answer


Learn to socialize, communicate, and network. The pro gaming industry is very small and niche. Learn to connect with everyone and anyone you can about it so"" ·" : "Every game is different. I think almost anyone can be a pro gamer if they start young. Reflexes"How hard is it to become an esports professional gamer""I really want to be a professional gamer, but my parents want""What age is too old to become a pro-gamer? - Quora""How to become a pro gamer within a month - Quora


Answer is posted for the following question.

How to become a pro gamer?

Answer


Myntra customer care number toll free toll free number is 1800-415-8744-3821-3940-4439

Note: The above number is provided by individual. So we dont gurantee the accuracy of the number. So before using the above number do your own research or enquiry.

Source: myntra.pissedconsumer.com


Answer is posted for the following question.

What is Myntra customer care number toll free?

Answer


  1. Open a file in Acrobat DC.
  2. Click on the “Edit PDF” tool in the right pane.
  3. Use Acrobat editing tools: Add new text, edit text, or update fonts using selections from the Format list.
  4. Save your edited PDF: Name your file and click the “Save” button.

Answer is posted for the following question.

How to be able to edit pdf?

Answer


Results 1 - 24 of 173 — ______ ROLE REQUIREMENTS : SOME SUPPORTING LEAD ROLES AND SOME CHARACTER ROLES .______ WE NEED MALE, .


Answer is posted for the following question.

How to become bengali actor?

Answer


The SPL version is definitely the way to go. Not only is it the easiest to read, but it's a part of PHP now, so will be familiar to many more people.

There's nothing "wrong" with the others, but as you stated, having all these different versions in one project isn't helping anyone.


Answer is posted for the following question.

Which implementation of iterator should i use , and why in PHP Server Side Scripting Language?

Answer


Keep reading to know more about the car stereos and how to choose the right one for your car. Brands of Car Music System. There are many reputed audio ."Pioneer Car Media Players · Car Media Players · Sony Car Media Players


Answer is posted for the following question.

How much is a car audio system?

Answer


1) After you complete the NEFT payment, you get a confirmation in a few hours. Then, when you go back to the portal and visit the payment page, the receipt number will have populated. 2) Also, its the last 12 digits of the Unique Beneficiary Account Number.

Answer is posted for the following question.

How to get mrv receipt after neft?

Answer


"

Python 2.6+

"
next(iter(your_list), None)"
"

If your_list can be None:

"
next(iter(your_list or []), None)"
"

Python 2.4

"
def get_first(iterable, default=None):"    if iterable:"        for item in iterable:"            return item"    return default"
"

Example:

"
x = get_first(get_first_list())"if x:"    ..."y = get_first(get_second_list())"if y:"    ..."
"

Another option is to inline the above function:

"
for x in get_first_list() or []:"    # process x"    break # process at most one item"for y in get_second_list() or []:"    # process y"    break"
"

To avoid break you could write:

"
for x in yield_first(get_first_list()):"    x # process x"for y in yield_first(get_second_list()):"    y # process y"
"

Where:

"
def yield_first(iterable):"    for item in iterable or []:"        yield item"        return"
"

Answer is posted for the following question.

Python idiom to return first item or none in Python Programming Language?

Answer


You can create it using nested lists:

matrix = [[a,b],[c,d],[e,f]]

If it has to be dynamic it's more complicated, why not write a small class yourself?

class Matrix(object):"    def __init__(self, rows, columns, default=0):"        self.m = []"        for i in range(rows):"            self.m.append([default for j in range(columns)])""    def __getitem__(self, index):"        return self.m[index]

This can be used like this:

m = Matrix(10,5)"m[3][6] = 7"print m[3][6] // -> 7

I'm sure one could implement it much more efficient. :)

If you need multidimensional arrays you can either create an array and calculate the offset or you'd use arrays in arrays in arrays, which can be pretty bad for memory. (Could be faster though…) I've implemented the first idea like this:

class Matrix(object):"    def __init__(self, *dims):"        self._shortcuts = [i for i in self._create_shortcuts(dims)]"        self._li = [None] * (self._shortcuts.pop())"        self._shortcuts.reverse()""    def _create_shortcuts(self, dims):"        dimList = list(dims)"        dimList.reverse()"        number = 1"        yield 1"        for i in dimList:"            number *= i"            yield number""    def _flat_index(self, index):"        if len(index) != len(self._shortcuts):"            raise TypeError()""        flatIndex = 0"        for i, num in enumerate(index):"            flatIndex += num * self._shortcuts[i]"        return flatIndex""    def __getitem__(self, index):"        return self._li[self._flat_index(index)]""    def __setitem__(self, index, value):"        self._li[self._flat_index(index)] = value

Can be used like this:

m = Matrix(4,5,2,6)"m[2,3,1,3] = 'x'"m[2,3,1,3] // -> 'x'

Answer is posted for the following question.

Hmmm. Need help. Listen Multidimensional array in Python Programming Language?

Answer


There is a number of ways to do it, PyQt4 provides enough information about method names for any object inspecting IDE:

>>> from PyQt4 import QtGui">>> dir(QtGui.QToolBox) "['Box', ... contextMenuPolicy', 'count', 'create', 'currentChanged'...]

All those functions are built-in. This means that you have to push some IDEs slightly to notice them. Be aware that there are no docstrings in compiled PyQt and methods have a funny signature.

Other possibility is using QScintilla2 and.api file generated during PyQt4 build process. Eric4 IDE is prepared exactly for that.

Komodo IDE/Komodo Edit and a CIX file (download here) that I hacked together not so long ago:

Screenshot 1

and,

Screenshot 2

Edit: Installation instructions for Komodo 5:

  1. Edit -> Preferences -> Code Intelligence
  2. Add an API Catalog...
  3. Select CIX file, press Open
  4. There is no point 4.


Answer is posted for the following question.

Autocompletion not working with pyqt4 and pykde4 in most of the ides in Python Programming Language?

Answer


How Much Does the K Ring Cost? The K-Ring is £99 from the online store and is available across Europe.

Answer is posted for the following question.

How much is a k ring contactless?

Answer


1 answer"Bill Paid DateWhat does it even mean? The Bill Paid Date is the date your funds are sent to the biller or payee. What is BPF ? There may be more than one .


Answer is posted for the following question.

What does bpf payment mean?

Answer


Time abuse refers to the fact that at a certain point, bacteria will start to grow in cooked foods such as meats, fish, pork, and poultry that have been left out at room temperatures. In about two hours, these bacteria can make food unsafe, potentially causing food poisoning if a person consumes it.

Answer is posted for the following question.

What is time temperature abuse in a food service?

Answer


We can't guess what you are trying to do, nor what's in your code, not what "setting many different codecs" means, nor what u"string" is supposed to do for you.

Please change your code to its initial state so that it reflects as best you can what you are trying to do, run it again, and then edit your question to provide (1) the full traceback and error message that you get (2) snippet encompassing the last statement in your script that appears in the traceback (3) a brief description of what you want the code to do (4) what version of Python you are running.

Edit after details added to question:

(0) Let's try some transformations on the failing statement:

Original:
code>print "Error reading file %s"%u"%s/%s"%(folder, f)
code>print "Error reading file %s" % u"%s/%s" % (folder, f)
code>print ("Error reading file %s" % u"%s/%s") % (folder, f)
code>print u"Error reading file %s/%s" % (folder, f)

Is that really what you intended? Suggestion: construct the path ONCE, using a better method (see point (2) below).

(1) In general, use repr(foo) or for diagnostics. That way, your diagnostic code is much less likely to cause an exception (as is happening here) AND you avoid ambiguity. Insert the statement print repr(folder), repr(f) before you try to get the size, rerun, and report back.

(2) Don't make paths by u"%s/%s" % (folder, filename) ... use os.path.join(folder, filename)

(3) Don't have bare excepts, check for known problems. So that unknown problems don't remain unknown, do something like this:

try:"    some_code()"except ReasonForBaleOutError:"    continue"except: "    # something's gone wrong, so get diagnostic info"    print repr(interesting_datum_1), repr(interesting_datum_2)"    # ... and get traceback and error message"    raise

A more sophisticated way would involve logging instead of printing, but the above is much better than not knowing what's going on.

Further edits after rtm("os.walk"), remembering old legends, and re-reading your code:

(4) os.walk() walks over the whole tree; you don't need to call it recursively.

(5) If you pass a unicode string to os.walk(), the results (paths, filenames) are reported as unicode. You don't need all that u"blah" stuff. Then you just have to choose how you display the unicode results.

(6) Removing paths with "$" in them: You must modify the list in situ but your method is dangerous. Try something like this:

for i in xrange(len(folders), -1, -1):"    if '$' in folders[i]:"        del folders[i]

(7) Your refer to files by joining a folder name and a file name. You are using the ORIGINAL folder name; when you rip out the recursion, this won't work; you'll need to use the currently-discarded content[0] value reported by os.walk.

(8) You should find yourself using something very simple like:

for folder, subfolders, filenames in os.walk(unicoded_top_folder):

There's no need for generator = os.walk(...); try: content = generator.next() etc and BTW if you ever need to do generator.next() in the future, use except StopIteration instead of a bare except.

(9) If the caller provides a non-existent folder, no exception is raised, it just does nothing. If the provided folder is exists but is empty, ditto. If you need to distinguish between these two scenarios, you'll need to do extra testing yourself.

Response to this comment from the OP: """Thanks, please read the info repr() has shown in the first post. I don't know why it printed so many different items, but it looks like they all have problems. And the common thing between all of them is they are .ink files. May that be the problem? Also, in the last ones, the firefox ones, it prints ( Modalitrovvisoria) while the real file name from Explorer contains ( Modalità provvisoria)""/p>

(10) Umm that's not ".INK".lower(), it's ".LNK".lower() ... perhaps you need to change the font in whatever you're reading that with.

(11) The fact that the "problem" file names all end in ".lnk" /may/ be something to do with os.walk() and/or Windows doing something special with the names of those files.

(12) I repeat here the Python statement that you used to produce that output, with some whitespace introduced :

print repr("    "Error reading file %s" "    % u"%s/%s" % ("        folder.decode('utf-8','ignore'),"        f.decode('utf-8','ignore')"        )"    )

It seems that you have not read, or not understood, or just ignored, the advice I gave you in a comment on another answer (and that answerer's reply): UTF-8 is NOT relevant in the context of file names in a Windows file system.

We are interested in exactly what folder and f refer to. You have trampled all over the evidence by attempting to decode it using UTF-8. You have compounded the obfuscation by using the "ignore" option. Had you used the "replace" option, you would have seen "( Modalitufffdrovvisoria)". The "ignore" option has no place in debugging.

In any case, the fact that some of the file names had some kind of error but appeared NOT to lose characters with the "ignore" option (or appeared NOT to be mangled) is suspicious.

Which part of """Insert the statement print repr(folder), repr(f) """ did you not understand? All that you need to do is something like this:

print "Some meaningful text" # "error reading file" isn't"print "folder:", repr(folder)"print "f:", repr(f)

(13) It also appears that you have introduced UTF-8 elsewhere in your code, judging by the traceback: self.exploreRec(("%s/%s"%(folder, f)).encode("utf-8"), treshold)

I would like to point out that you still do not know whether folder and f refer to str objects or unicode objects, and two answers have suggested that they are very likely to be str objects, so why introduce blahbah.encode() ??

A more general point: Try to understand what your problem(s) is/are, BEFORE changing your script. Thrashing about trying every suggestion coupled with near-zero effective debugging technique is not the way forward.

(14) When you run your script again, you might like to reduce the volume of the output by running it over some subset of C: ... especially if you proceed with my original suggestion to have debug printing of ALL file names, not just the erroneous ones (knowing what non-error ones look like could help in understanding the problem).

Response to Bryan McLemore's "clean up" function:

(15) Here is an annotated interactive session that illustrates what actually happens with os.walk() and non-ASCII file names:

C:junk	erabytest>dir"[snip]" Directory of C:junk	erabytest""20/11/2009  01:28 PM              ."20/11/2009  01:28 PM              .."20/11/2009  11:48 AM              empty"20/11/2009  01:26 PM                11 Hašek.txt"20/11/2009  01:31 PM             1,419 tbyte1.py"29/12/2007  09:33 AM                 9 Ð.txt"               3 File(s)          1,439 bytes"[snip]""C:junk	erabytest>python26python"Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] onwin32"Type "help", "copyright", "credits" or "license" for more information.">>> from pprint import pprint as pp">>> import os

os.walk(unicode_string) -> results in unicode objects

>>> pp(list(os.walk(ur"c:junk	erabytest")))"[(u'c:junk	erabytest',"  [u'empty'],"  [u'Hau0161ek.txt', u'tbyte1.py', u'xd0.txt'])," (u'c:junk	erabytestempty', [], [])]

os.walk(str_string) -> results in str objects

>>> pp(list(os.walk(r"c:junk	erabytest")))"[('c:junk	erabytest',"  ['empty'],"  ['Hax9aek.txt', 'tbyte1.py', 'xd0.txt'])," ('c:junk	erabytestempty', [], [])]

cp1252 is the encoding I'd expect to be used on my system ...

>>> u'u0161'.encode('cp1252')"'x9a'">>> 'Hax9aek'.decode('cp1252')"u'Hau0161ek'

decoding the str with UTF-8 doesn't work, as expected

>>> 'Hax9aek'.decode('utf8')"Traceback (most recent call last):"  File stdin, line 1, in 

ANY random string of bytes can be decoded without error using latin1

>>> 'Hax9aek'.decode('latin1')"u'Hax9aek'

BUT U+009A is a control character (SINGLE CHARACTER INTRODUCER), i.e. meaningless gibberish; absolutely nothing to do with the correct answer

>>> unicodedata.name(u'u0161')"'LATIN SMALL LETTER S WITH CARON'">>>

(16) That example shows what happens when the character is representable in the default character set; what happens if it's not? Here's an example (using IDLE this time) of a file name containing CJK ideographs, which definitely aren't representable in my default character set:

IDLE 2.6.4      ">>> import os">>> from pprint import pprint as pp

repr(Unicode results) looks fine

>>> pp(list(os.walk(ur"c:junk	erabytestchinese")))"[(u'c:junk	erabytestchinese', [], [u'nihaou4f60u597d.txt'])]

and the unicode displays just fine in IDLE:

>>> print list(os.walk(ur"c:junk	erabytestchinese"))[0][2][0]"nihao你好.txt

The str result is evidently produced by using .encode(whatever, "replace") -- not very useful e.g. you can't open the file by passing that as the file name.

>>> pp(list(os.walk(r"c:junk	erabytestchinese")))"[('c:junk	erabytestchinese', [], ['nihao??.txt'])]

So the conclusion is that for best results, one should pass a unicode string to os.walk(), and deal with any display problems.


Answer is posted for the following question.

Python, unicodedecodeerror in Python Programming Language?

Answer


Even though a feared Alpine Fortress last stand of the Nazi Regime in the Alps failed to materialize late in World War II, the Allies launched a devastating air raid on the Berchtesgaden area in the spring of 1945. The 25 April bombing of Obersalzberg did little damage to the town.

Answer is posted for the following question.

What is berchtesgaden famous for?

Answer


How to apply. If you are dealing with a department, ask them to request a new vendor on SAP. Once they have done so Procurement and Payment Services (PPS) will contact you and, if it is deemed a valid request, you will be asked to complete a vendor application form and supply the necessary original documentation.

Answer is posted for the following question.

How to become a uct vendor?

Answer


Django provides an utility function to remove HTML tags:

from django.utils.html import strip_tags""my_string = '
Hello, world
'"my_string = strip_tags(my_string)"print(my_string)"# Result will be "Hello, world" without the
elements

This function used to be unsafe on older Django version (before 1.7) but nowadays it is completely safe to use it. Here is an article that reviewed this issue when it was relevant.


Answer is posted for the following question.

How to strip html/javascript from text input in django in Python Programming Language?

Answer


— Heat the oil in a sauté pan or large frying pan, add the onion and carrots and cook over a medium heat for about 5 mins, stirring occasionally, until ."Rating: 3.5 · 856 votes · 55 mins · Calories: 385


Answer is posted for the following question.

How to cook mince?

Answer


— We share the steps to take to become a Taobao agent and solutions to problems encountered when running a Taobao business.


Answer is posted for the following question.

How to become taobao agent in malaysia?

Answer


How to Open DBX Files in Windows ? · Run Free DBX File Viewer Tool on Windows. · Select, DBX File exported from Outlook Express. · Click on the left side panel .


Answer is posted for the following question.

How to read dbx files?


Wait...