python Programming Glossary: must
What is a metaclass in Python? http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python the whole class yourself. Since classes are objects they must be generated by something. When you use the class keyword Python.. using __init__ . These are called metaclasses damn it It must mean something Why the hell would you use metaclasses Now the..
In Python, how do I determine if an object is iterable? http://stackoverflow.com/questions/1952464/in-python-how-do-i-determine-if-an-object-is-iterable object If it looks like a duck and quacks like a duck it must be a duck . By emphasizing interfaces rather than specific types..
The Python yield keyword explained http://stackoverflow.com/questions/231767/the-python-yield-keyword-explained improve this question To understand what yield does you must understand what generators are. And before generators come iterables... that you will only need to read once. To master yield you must understand that when you call the function the code you have..
Why do people write #!/usr/bin/env python on the first line of a Python script? http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script In Unix an executable file that's meant to be interpreted must indicate what interpreter to use by having a # at the start..
Short Description of Python Scoping Rules http://stackoverflow.com/questions/291978/short-description-of-python-scoping-rules And maybe lambda functions pass a bit differently There must be a simple reference or algorithm somewhere. It's a confusing..
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 cases the thread is holding a critical resource that must be closed properly the thread has created several other threads.. properly the thread has created several other threads that must be killed as well. The nice way of handling this if you can..
In a django form, How to make a field readonly (or disabled) so that it cannot be edited? http://stackoverflow.com/questions/324477/in-a-django-form-how-to-make-a-field-readonly-or-disabled-so-that-it-cannot-b For example when creating a new Item model all fields must be editable but while updating the record is there a way to.. entry on the widget and prevent malicious POST hacks you must scrub the input in addition to setting the readonly attribute..
*args and **kwargs? [duplicate] http://stackoverflow.com/questions/3394835/args-and-kwargs can also use both in the same function definition but args must occur before kwargs . You can also use the and syntax when calling..
How to limit execution time of a function call in Python http://stackoverflow.com/questions/366682/how-to-limit-execution-time-of-a-function-call-in-python function execution time from my code I guess the solution must utilize another thread. python multithreading share improve..
How do I unload (reload) a Python module? http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module the module are not rebound to refer to the new objects and must be updated in each namespace where they occur if that is desired...
Python code to pick out all possible combinations from a list? http://stackoverflow.com/questions/464864/python-code-to-pick-out-all-possible-combinations-from-a-list and am wary of using it. Plus I have a feeling there must be a more elegant solution. The only thing that occurs to me..
Setting the correct encoding when piping stdout in python http://stackoverflow.com/questions/492483/setting-the-correct-encoding-when-piping-stdout-in-python your terminal application is using. If you are piping you must encode it yourself. A rule of thumb is Always use unicode internally...
What's the difference between list and tuples in Python? http://stackoverflow.com/questions/626759/whats-the-difference-between-list-and-tuples-in-python generally have different types and the length of the tuple must be fixed. In a list the values all have the same type and the..
list comprehension without [ ], Python http://stackoverflow.com/questions/9060653/list-comprehension-without-python a list ''.join str _ for _ in xrange 10 '0123456789' join must take an iteratable. Apparently join 's argument is str _ for..
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 and all the items in the previous intermediate result must be copied over as well as a few new ones added at the end ...
python database / sql programming - where to start http://stackoverflow.com/questions/1407248/python-database-sql-programming-where-to-start one provided by Python default installation then great. Must be open source available on Windows and Linus. Better if SQL..
Obtain File size with os.path.getsize() in Python 2.7.5 http://stackoverflow.com/questions/17410628/obtain-file-size-with-os-path-getsize-in-python-2-7-5 Minimum Every Software Developer Absolutely Positively Must Know About Unicode and Character Sets No Excuses by Joel Spolsky..
Python integer incrementing with ++ [duplicate] http://stackoverflow.com/questions/2632677/python-integer-incrementing-with I can't find anything about this in the Python docs. Must I really subject myself to number number 1 Doesn't people use..
py2exe com dll problem http://stackoverflow.com/questions/3126379/py2exe-com-dll-problem 0 None indexMenu 1 return idCmd idCmdFirst # Must return number of menu items we added. except Exception e alertError..
Get hard disk serial number using Python on Linux http://stackoverflow.com/questions/4193514/get-hard-disk-serial-number-using-python-on-linux import sys os fcntl struct if os.geteuid 0 print ERROR Must be root to use sys.exit 1 with open sys.argv 1 rb as fd # tediously..
How to keep comments while parsing XML using Python / ElementTree http://stackoverflow.com/questions/4474754/how-to-keep-comments-while-parsing-xml-using-python-elementtree ElementTree' except ImportError e print ' ' print ' Error Must install either ElementTree or lxml.' print ' ' raise ImportError..
Repeated host lookups failing in urllib2 http://stackoverflow.com/questions/4555026/repeated-host-lookups-failing-in-urllib2 page urllib2.urlopen url f.write page.read page.close # Must remember to close The semaphore is a BoundedSemaphore to constrain..
Textually diffing JSON http://stackoverflow.com/questions/4599456/textually-diffing-json param maxrecursion The maximum depth to recurse. Must be a positive integer. return None the return value is in the..
Running three commands in the same process with Python http://stackoverflow.com/questions/5087302/running-three-commands-in-the-same-process-with-python shutdown exit cmd.stdin.write batch cmd.stdin.flush # Must include this to ensure data is passed to child process result.. ... exit ... cmd.stdin.write batch 59 cmd.stdin.flush # Must include this to ensure data is passed to child process result..
Serializing SQLAlchemy models for a REST API while respecting access control? http://stackoverflow.com/questions/5232461/serializing-sqlalchemy-models-for-a-rest-api-while-respecting-access-control via a mixin class Serializer object __public__ None Must be implemented by implementors __internal__ None Must be implemented.. None Must be implemented by implementors __internal__ None Must be implemented by implementors def to_serializable_dict self..
ImportError: No module named copy_reg pickle http://stackoverflow.com/questions/556269/importerror-no-module-named-copy-reg-pickle ideas as to why this happens Method of Reproduction Note Must do step 1 on a Windows PC and steps 3 and 4 on a Linux PC. 1..
Python file modes detail http://stackoverflow.com/questions/654499/python-file-modes-detail case 'r' if rwa bad_mode PyErr_SetString PyExc_ValueError Must have exactly one of read write append mode goto error rwa..
Python timedelta in years http://stackoverflow.com/questions/765797/python-timedelta-in-years from_date.replace year from_date.year years except # Must be 2 29 assert from_date.month 2 and from_date.day 29 # can..
Paramiko and exec_command - killing remote process? http://stackoverflow.com/questions/7734679/paramiko-and-exec-command-killing-remote-process True try rl wl xl select.select channel 0.0 if len rl 0 # Must be stdout print channel.recv 1024 except KeyboardInterrupt print.. True try rl wl xl select.select channel 0.0 if len rl 0 # Must be stdout print channel.recv 1024 except KeyboardInterrupt print..
Complex foreign key constraint in SQLAlchemy http://stackoverflow.com/questions/8394177/complex-foreign-key-constraint-in-sqlalchemy to be beneficial rather than harmful at a first glance. Must have been fixed for the newer versions without changing the..
Understanding python imports http://stackoverflow.com/questions/900591/understanding-python-imports global namespace import x # the module as a whole x.a # Must pick items out of the module x.b from x import a b # two things..
Common pitfalls in Python [duplicate] http://stackoverflow.com/questions/1011431/common-pitfalls-in-python pdf . What else should I add to my list of things to MUST avoid Always import modules the same way e.g. from y import..
How can I build my C extensions with MinGW-w64 in Python? http://stackoverflow.com/questions/11182765/how-can-i-build-my-c-extensions-with-mingw-w64-in-python generate wrappers e.g. swig c python myExtension.i wrapper MUST be compiled with MS_WIN64 or your computer will crash when you..
How can I save my secret keys and password securely in my version control system? http://stackoverflow.com/questions/11575398/how-can-i-save-my-secret-keys-and-password-securely-in-my-version-control-system and salt fixed is defined inside these scripts and you MUST ensure that .gitencrypt is never actually pushed. Example clean_filter_openssl..
Encrypt & Decrypt using PyCrypto AES 256 http://stackoverflow.com/questions/12524994/encrypt-decrypt-using-pycrypto-aes-256 BLOCK_SIZE 32 def encrypt message passphrase # passphrase MUST be 16 24 or 32 bytes long how can I do that IV Random.new .read..
Writing Python bindings for C++ code that use OpenCV http://stackoverflow.com/questions/12957492/writing-python-bindings-for-c-code-that-use-opencv etc. import_array This is a function from NumPy that MUST be called. Do other stuff The conversions functions above are..
Encoding binary data within XML : alternatives to base64 http://stackoverflow.com/questions/17301940/encoding-binary-data-within-xml-alternatives-to-base64 have to worry about unterminated UTF8 chars . Note that we MUST USE the 2 byte or above UTF 8 characters encoding space to reach..
Could not find a version that satisfies the requirement pytz http://stackoverflow.com/questions/18230956/could-not-find-a-version-that-satisfies-the-requirement-pytz in PEP440 which specifies that Public version identifiers MUST comply with the following scheme N .N a b c rc N .postN .devN..
Python for a Perl programmer http://stackoverflow.com/questions/2283034/python-for-a-perl-programmer on Stack Overflow. In particular Python Things one MUST avoid and Python 2.x gotcha ™s and landmines are well worth a..
Python: How do I create sequential file names? http://stackoverflow.com/questions/2400827/python-how-do-i-create-sequential-file-names of the code. It can't overwrite any existing files and it MUST be created. I'm stumped. python filesystems share improve..
How to synchronize a python dict with multiprocessing http://stackoverflow.com/questions/2545961/how-to-synchronize-a-python-dict-with-multiprocessing Ctrl C . Annoying problems The Manager's register methods MUST be called before the manager is started otherwise you will get..
how to tell if a string is base64 or not http://stackoverflow.com/questions/271657/how-to-tell-if-a-string-is-base64-or-not atom. RFC2047 §5 explicitly denies this An 'encoded word' MUST NOT appear within a 'quoted string'. The accepted way to encode..
How to implement “autoincrement” on Google AppEngine http://stackoverflow.com/questions/3985812/how-to-implement-autoincrement-on-google-appengine Numbers shipping label numbers or the like. A number MUST NOT BE used twice Every number SHOULD BE used when exactly all..
Python - can I detect unicode string language code? http://stackoverflow.com/questions/4545977/python-can-i-detect-unicode-string-language-code chunks key api_key target en doseq 1 # the request length MUST be 5000 if len data 5000 raise ValueError request is too long.. t in chunks key api_key doseq True # the request length MUST be 5000 if len data 5000 raise ValueError request is too long..
How to detect motion between two PIL images? (wxPython webcam integration example included) http://stackoverflow.com/questions/5524179/how-to-detect-motion-between-two-pil-images-wxpython-webcam-integration-exampl return percchange if __name__ __main__ # image1 image2 MUST be legit paths image1 C Path To Your First Image.jpg image2..
Improving Python/django view code http://stackoverflow.com/questions/6245755/improving-python-django-view-code widgets 'user' forms.HiddenInput # initial data MUST be used to assign this A simple ModelForm based on the UserProfile..
Sending Email With Python http://stackoverflow.com/questions/6270782/sending-email-with-python that you have not gone through the Python tutorial it is a MUST if you want to get anywhere in Python the documentation is mostly..
Getting started with secure AWS CloudFront streaming with Python http://stackoverflow.com/questions/6549787/getting-started-with-secure-aws-cloudfront-streaming-with-python and AWS_SECRET_ACCESS_KEY s3 boto.connect_s3 #bucket name MUST follow dns guidelines new_bucket_name stream.example.com bucket..
|