Python

TwitterFacebook
Get flash to fully experience Pearltrees
django

Python: Lambda Functions

http://www.secnetix.de/olli/Python/lambda_functions.hawk Python supports the creation of anonymous functions (i.e. functions that are not bound to a name) at runtime, using a construct called "lambda". This is not exactly the same as lambda in functional programming languages, but it is a very powerful concept that's well integrated into Python and is often used in conjunction with typical functional concepts like filter() , map() and reduce() . This piece of code shows the difference between a normal function definition ("f") and a lambda function ("g"):
Original version by Andrew Dalke with a major update by Raymond Hettinger http://wiki.python.org/moin/HowTo/Sorting

HowTo/Sorting

http://www.python.org/dev/peps/pep-0257/ What is a Docstring?

PEP 257 -- Docstring Conventions

http://code.activestate.com/recipes/52234-guaranteed-stable-sort-with-the-decorate-sort-unde/ "decorate-sort-undecorate" is a general and common idiom that allows very flexible and speedy sorting of Python sequences. An auxiliary list is first built (the 'decorate' step) where each item is made up of all sort-keys (in descending order of significance) of the corresponding item of the input sequence (must include all of the information in the whole corresponding item, and/or an index to it so we can fetch it back [or reconstruct it] in the third step). This is then sorted by its builtin sort method without arguments.

guaranteed-stable sort with the decorate-sort-undecorate idiom (

Save the script as 'pyline' somewhere on your path, e.g.

Pyline: a grep-like, sed-like command-line tool. « ActiveState C

http://code.activestate.com/recipes/437932-pyline-a-grep-like-sed-like-command-line-tool/
Introduction The game you played yesterday uses files to store game saves. The order you placed yesterday was saved in a file.

File Management in Python

http://www.devshed.com/c/a/Python/File-Management-in-Python/
http://effbot.org/zone/python-list.htm You can use the list type to implement simple data structures, such as stacks and queues.

An Introduction to Python Lists

The Python Tutorial — Python v2.6.4 documentation

http://docs.python.org/tutorial/ Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming.
http://kogs-www.informatik.uni-hamburg.de/~meine/python_tricks

Python Tricks

Here, I am collecting python snippets that I find enlightening and/or just useful. On a subpage , you find a JPype-using hack to access Weka's Java classes from Python.
by leonardo maffi

Python best practices

Managing DNS zone files with dnspython

I've been using dnspython lately for transferring some DNS zone files from one name server to another. I found the package extremely useful, but poorly documented, so I decided to write this post as a mini-tutorial on using dnspython.

Python Exception Handling Techniques - Doug Hellmann

Error reporting and processing through exceptions is one of Python’s key features.