ˇ@

Home 

python Programming Glossary: no

What is a metaclass in Python?

http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python

say they're just OO concepts but this one is tricky. I know it has something to do with introspection but it's still unclear.. Foo object ... pass ... return Foo # return the class not an instance ... else ... class Bar object ... pass ... return.. 'foo' print MyClass # the function returns a class not an instance class '__main__.Foo' print MyClass # you can create..

Which Python memory profiler is recommended? [closed]

http://stackoverflow.com/questions/110259/which-python-memory-profiler-is-recommended

Python memory profiler is recommended closed I want to know the memory usage of my Python application and specifically.. usage of my Python application and specifically want to know what code blocks portions or objects are consuming most memory... PySizer and Heapy . I haven't tried anyone so I wanted to know which one is the best considering Gives most details. I have..

Remove items from a list while iterating in Python

http://stackoverflow.com/questions/1207406/remove-items-from-a-list-while-iterating-in-python

That would then be just. somelist x for x in somelist if not determine x EDIT somelist x for x in somelist if not determine.. if not determine x EDIT somelist x for x in somelist if not determine x Brandon Corfman is correct you will lose reference.. Cides' suggestion that uses itertools . However there is no non iterator filterfalse so it will have to be. from itertools..

The meaning of a single- and a double-underscore before an object name in Python

http://stackoverflow.com/questions/1301346/the-meaning-of-a-single-and-a-double-underscore-before-an-object-name-in-python

the attribute or method is intended to be private. However nothing special is done with the name itself. To quote PEP 8 _single_leading_underscore.. weak internal use indicator. E.g. from M import does not import objects whose name starts with an underscore. Double.. stdin line 1 in module AttributeError myClass instance has no attribute '__superprivate' print mc._semiprivate world print..

Fastest way to list all primes below N in python

http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python

even faster EDIT This code has a flaw Since numbers is an unordered set there is no guarantee that numbers.pop will remove.. code has a flaw Since numbers is an unordered set there is no guarantee that numbers.pop will remove the lowest number from.. in get_primes 530 True EDIT The rank so far pure python no external sources all primes below 1 million Sundaram's Sieve..

The Python yield keyword explained

http://stackoverflow.com/questions/231767/the-python-yield-keyword-explained

it do For example I'm trying to understand this code def node._get_child_candidates self distance min_dist max_dist if self._leftchild.. is the caller result candidates list self while candidates node candidates.pop distance node._get_dist obj if distance max_dist.. list self while candidates node candidates.pop distance node._get_dist obj if distance max_dist and distance min_dist result.extend..

Is there any way to kill a Thread in Python?

http://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread-in-python

'''Raises an exception in the threads with id tid''' if not inspect.isclass exctype raise TypeError Only types can be raised.. exctype raise TypeError Only types can be raised not instances res ctypes.pythonapi.PyThreadState_SetAsyncExc tid.. class that supports raising exception in the thread from another thread. ''' def _get_my_tid self determines this self's..

*args and **kwargs? [duplicate]

http://stackoverflow.com/questions/3394835/args-and-kwargs

names args and kwargs are only by convention but there's no need to use them. You would use args when you're not sure how.. no need to use them. You would use args when you're not sure how many arguments might be passed to your function i.e... kwargs allows you to handle named arguments that you have not defined in advance def table_things kwargs ... for name value..

What kinds of patterns could I enforce on the code to make it easier to translate to another programming language?

http://stackoverflow.com/questions/3455456/what-kinds-of-patterns-could-i-enforce-on-the-code-to-make-it-easier-to-translat

I enforce on the code to make it easier to translate to another programming language I am setting out to do a side project.. goal of translating code from one programming language to another. The languages I am starting with are PHP and Python Python.. insights on how to make this less daunting please let me know. EDIT I am more interested in knowing what kinds of patterns..

Non-blocking read on a subprocess.PIPE in python

http://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python

it's output stream stdout . I want to be able to execute non blocking reads on its stdout. Is there a way to make .readline.. reads on its stdout. Is there a way to make .readline non blocking or to check if there is data on the stream before.. work under Windows and Linux. here is how I do it for now It's blocking on the .readline if no data is avaible p subprocess.Popen..

Old style and new style classes in Python

http://stackoverflow.com/questions/54867/old-style-and-new-style-classes-in-python

improve this question From http docs.python.org ref node33.html Up to Python 2.1 old style classes were the only flavour.. unify classes and types . A new style class neither more nor less than a user defined type. If x is an instance of a new.. by default . New style classes are created by specifying another new style class i.e. a type as a parent class or the top..

Making a flat list out of list of lists in Python [duplicate]

http://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python

1 in File line 1 in AttributeError 'NoneType' object has no attribute 'extend' python list share improve this question..

Python: How do I pass a variable by reference?

http://stackoverflow.com/questions/986006/python-how-do-i-pass-a-variable-by-reference

rebind the reference in the method the outer scope will know nothing about it and after you're done the outer reference.. the reference in the method the outer scope will know nothing about it and after you're done the outer reference will.. Since the parameter passed in is a reference to outer_list not a copy of it we can use the mutating list methods to change..

What is different between all these OpenCV Python interfaces?

http://stackoverflow.com/questions/10417108/what-is-different-between-all-these-opencv-python-interfaces

was only cv . Later OpenCV came with both cv and cv2 . Now there in the latest releases there is only the cv2 module and.. array slicing can be used like ROI array c1 c2 r1 r2 . No need of separate functions. To add two images there isn't a..

Using the Python NLTK (2.0b5) on the Google App Engine

http://stackoverflow.com/questions/1286301/using-the-python-nltk-2-0b5-on-the-google-app-engine

folder of the GAE project type 'exceptions.ImportError' No module named nltk Traceback most recent call last File base.. internals.py line 19 in module from nltk import __file__ Note this is how the error looks in the logs when uploaded to GAE...

How can I quantify difference between two images?

http://stackoverflow.com/questions/189943/how-can-i-quantify-difference-between-two-images

RGB channels the last array axis to obtain intensity. No need to do it for grayscale images e.g. .pgm def to_grayscale.. average over the last axis color channels else return arr Normalization is trivial you may choose to normalize to 0 1 instead.. 255 rng Run the main function if __name__ __main__ main Now you can put this all in a script and run against two images...

The problem with installing PIL using virtualenv or buildout

http://stackoverflow.com/questions/2485295/the-problem-with-installing-pil-using-virtualenv-or-buildout

recent call last File stdin line 1 in module ImportError No module named PIL I see that easy_install pack PIL into the Egg..

Print in terminal with colors using Python?

http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python

you can do something like print bcolors.WARNING Warning No active frommets remain. Continue bcolors.ENDC This will work..

How do I filter ForeignKey choices in a Django ModelForm?

http://stackoverflow.com/questions/291945/how-do-i-filter-foreignkey-choices-in-a-django-modelform

How to add to the pythonpath in windows 7?

http://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7

read the coltrane module and generated this error Error No module named coltrane python django windows 7 pythonpath ..

Using global variables in a function other than the one that created them

http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them

of globvar globvar 1 def print_globvar print globvar # No need for global declaration to read value of globvar set_globvar_to_one..

How to improve performance of this code?

http://stackoverflow.com/questions/4295799/how-to-improve-performance-of-this-code

openlist.put heuristicf formation node formation 0 None closedlist while 1 try f current openlist.get except IndexError.. 1 try f current openlist.get except IndexError current None if current is None print No solution found return None if.. openlist.get except IndexError current None if current is None print No solution found return None if solutionf current.arrangement..

What's the proper way to install pip, virtualenv, and distribute for Python?

http://stackoverflow.com/questions/4324558/whats-the-proper-way-to-install-pip-virtualenv-and-distribute-for-python

I originally pulled these instructions from Jesse Noller's blog post So you want to use Python on the Mac . I like.. distribute_setup.py sudo python distribute_setup.py No more setuptools and easy_install To really follow that Python.. INITIAL_ENV bin pip install virtualenv VERSION.tar.gz Now you can use your bootstrap environment to create more # Create..

Stop reading process output in Python without hang?

http://stackoverflow.com/questions/4417962/stop-reading-process-output-in-python-without-hang

terminate on process.terminate then the scripts hangs. No threads no signals solution import collections import subprocess..

Comprehension for flattening a sequence of sequences?

http://stackoverflow.com/questions/457215/comprehension-for-flattening-a-sequence-of-sequences

that is targeted on my question even if the answer is No you can't. . python sequences list comprehension share improve..

Accessing dict keys like an attribute in Python?

http://stackoverflow.com/questions/4984647/accessing-dict-keys-like-an-attribute-in-python

args kwargs self.__dict__ self Some pros It actually works No dictionary class methods are shadowed e.g. .keys work just fine..

Old style and new style classes in Python

http://stackoverflow.com/questions/54867/old-style-and-new-style-classes-in-python

inheritance. Python 3 only has new style classes . No matter if you subclass from object or not classes are new style..

What is monkey patch?

http://stackoverflow.com/questions/5626193/what-is-monkey-patch

terminology monkeypatching share improve this question No it's not like any of those things. It's simply the dynamic replacement..

No module named pkg_resources

http://stackoverflow.com/questions/7446187/no-module-named-pkg-resources

module named pkg_resources I'm deploying a Django app to a.. from pkg_resources import load_entry_point ImportError No module named pkg_resources pkg_resources appears to be distributed..

Django dynamic model fields

http://stackoverflow.com/questions/7933596/django-dynamic-model-fields

Abstract specification for arbitrary data fields. Not used for holding data itself but metadata about the fields... models.CharField max_length 1024 class Meta abstract True Note how CustomDataField has a ForeignKey to Site each Site will.. it's too much of a hack. Schema less solutions like NoSQL. I have nothing against them but they're still not a good..

Converting a String to Dictionary?

http://stackoverflow.com/questions/988228/converting-a-string-to-dictionary

structures strings numbers tuples lists dicts booleans and None. For example eval shutil.rmtree 'mongo' Traceback most recent.. line 206 in rmtree names os.listdir path OSError Errno 2 No such file or directory 'mongo' ast.literal_eval shutil.rmtree..

CSRF verification failed. Request aborted

http://stackoverflow.com/questions/10388033/csrf-verification-failed-request-aborted

However if it is a RequestContext problem I really have NO idea on where and how to use it. I want everything to happen..

Tkinter message box

http://stackoverflow.com/questions/1052420/tkinter-message-box

a fairly simple message box in tkinter that has an YES and NO buttons. When I push the YES button internally it must go and.. it must go and write to a file YES. Similarly when NO is pushed file must be written a NO.Any idea of how I could.. YES. Similarly when NO is pushed file must be written a NO.Any idea of how I could do this python tkinter messagebox ..

Python TkInter - AttributeError: 'NoneType' object has no attribute 'get'

http://stackoverflow.com/questions/1101750/python-tkinter-attributeerror-nonetype-object-has-no-attribute-get

200 root.minsize width 550 height 200 root.resizable width NO height NO label Label root text Enter text .grid row 2 column.. width 550 height 200 root.resizable width NO height NO label Label root text Enter text .grid row 2 column 0 sticky..

How to install MySQLdb (Python data access library to MySQL) on Mac OS X?

http://stackoverflow.com/questions/1448429/how-to-install-mysqldb-python-data-access-library-to-mysql-on-mac-os-x

Step 4 Originally required editing _mysql.c but is now NO LONGER NECESSARY. MySQLdb community seem to have fixed this..

What is internal representation of string in Python 3.x

http://stackoverflow.com/questions/1838170/what-is-internal-representation-of-string-in-python-3-x

python 3.x share improve this question There has been NO CHANGE in Unicode internal representation between Python 2.X.. representation between Python 2.X and 3.X. It's definitely NOT UTF 16. UTF anything is a byte oriented EXTERNAL representation...

Python: Random is barely random at all?

http://stackoverflow.com/questions/2145510/python-random-is-barely-random-at-all

# We've just calculated the log of the probability that NO # two matching pairs occur in the sample. The probability #..

Why is Django admin login giving me 403 CSRF error?

http://stackoverflow.com/questions/3678238/why-is-django-admin-login-giving-me-403-csrf-error

given for failure No CSRF or session cookie. I have made NO customization to the barebones admin and when I inspect the..

What's the proper way to install pip, virtualenv, and distribute for Python?

http://stackoverflow.com/questions/4324558/whats-the-proper-way-to-install-pip-virtualenv-and-distribute-for-python

to my answer to SO question 4314376 SO user Glyph stated NO. NEVER EVER do sudo python setup.py install whatever. Write..

Python-specific antipatterns and bad practices [closed]

http://stackoverflow.com/questions/576988/python-specific-antipatterns-and-bad-practices

print Divide by 0 attempt detected return None NO def safe_divide_1 x y if y 0 print Divide by 0 attempt detected.. YES def double_list items return item 2 for item in items NO def double_list items doubled_items for item in items doubled_items.append.. in range 10 yield i for number in gen print i #prints 0 9 NO #list comprehension would be used here but I did a for loop..

How to SWIG in VS2010?

http://stackoverflow.com/questions/5969173/how-to-swig-in-vs2010

d Linker Enable Incremental Linking set as No INCREMENTAL NO e Linker Input Additional Dependencies add PYTHON_LIB ... f..

Best scripting language for web development [duplicate]

http://stackoverflow.com/questions/739538/best-scripting-language-for-web-development

see Ruby Python Power Ruby vs. Python Bottom line There is NO wrong choice. Pick one and GO As far as your exact question..

What's the best SOAP library for Python 3.x? [closed]

http://stackoverflow.com/questions/7817303/whats-the-best-soap-library-for-python-3-x

can AFAIK only be used for implementing the server side. NO I don't want to migrate one of the discontinued Python 2 projects..

Complex foreign key constraint in SQLAlchemy

http://stackoverflow.com/questions/8394177/complex-foreign-key-constraint-in-sqlalchemy

. Voilá . Exactly what you wanted. All key columns NOT NULL Addressing the question of @yppercube in the comments.. to avoid entries with unknown association all key columns NOT NULL including foreign keys you can do that too. The circular.. integer PRIMARY KEY variable text choice_id integer NOT NULL CREATE TEMP TABLE variableoptions option_id integer PRIMARY..

In Python, how to list all characters matched by POSIX extended regex `[:space:]`?

http://stackoverflow.com/questions/8921365/in-python-how-to-list-all-characters-matched-by-posix-extended-regex-space

u' x1c' u' x1d' u' x1e' u' x1f' u' ' SPACE u' x85' u' xa0' NO BREAK SPACE u' u1680' OGHAM SPACE MARK u' u180e' MONGOLIAN VOWEL.. SEPARATOR u' u2029' PARAGRAPH SEPARATOR u' u202f' NARROW NO BREAK SPACE u' u205f' MEDIUM MATHEMATICAL SPACE u' u3000' IDEOGRAPHIC..

matplotlib: limits when using plot and imshow in same axes

http://stackoverflow.com/questions/9120749/matplotlib-limits-when-using-plot-and-imshow-in-same-axes

rid of example how problem looks like Note that there is NO white border directly after calling imshow only. My code looks..

Creating a logging handler to connect to Oracle?

http://stackoverflow.com/questions/935930/creating-a-logging-handler-to-connect-to-oracle

ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL # VINAY SAJIP BE LIABLE FOR ANY SPECIAL INDIRECT..