background preloader

Essential Python Reading List

Essential Python Reading List
Here’s my essential Python reading list. I’ve tried to order the items so you can pause or stop reading at any point: at every stage you’ll have learned about as much possible about Python for the effort you’ve put in. The Zen of Python The Zen of Python is so short I can include it here in its entirety. Typing import this in an interpreted session gives a pythonic spin on “Hello, world”. >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. If this doesn’t ring true, Python isn’t for you. Python Tutorial Your next stop should be the Python tutorial. start here The latest version (by which I mean the version corresponding to the most recent stable release of Python) can be found on the web at but I recommend you find and bookmark the same page from your local Python installation: it will be available offline, pages will load fractionally quicker, and you’re sure to be reading about the version of Python you’re actually running. What’s New?

Distutils-SIG Charter The Distutils-SIG exists to discuss the design, implementation, and maintenance of a suite of module distribution utilities for Python. These utilities are grouped in the 'distutils' package in Python. The goal of distutils is to make building, packaging, distributing, and installing Python modules, extensions, and applications painless and standardized. There are also third-party tools built on the top of distutils, that are using the Distutils mailing list as their home. Namely: setuptools zc.buildout If you are packaging a Python package, this SIG is probably a good starting point to ask questions. The goal of Distutils-SIG is also to try to catch the good bits and practices from third-party projects and insert them in Distutils itself to serve the community. What's Available Interested in learning more or trying out the Distutils?

Python functional programming for mathematicians « mvngu This tutorial discusses some techniques of functional programming that might be of interest to mathematicians or people who use Python for scientific computation. We first start off with a brief overview of procedural and object-oriented programming, and then discuss functional programming techniques. Along the way, we briefly review Python’s built-in support for functional programming, including filter(), lambda, map() and reduce(). Styles of programming Python supports several styles of programming. Another common style of programming is called object-oriented programming. Functional programming using map() Functional programming is yet another style of programming in which a program is decomposed into various functions. takes a function func and one or more sequences, and apply func to elements of those sequences. In many cases, using map() allows you to express the logic of your program in a concise manner without using list comprehension. Define small functions using lambda

ctypes tutorial Note: The code samples in this tutorial uses doctest to make sure that they actually work. Since some code samples behave differently under Linux, Windows, or Mac OS X, they contain doctest directives in comments. Note: Quite some code samples references the ctypes c_int type. ctypes exports the cdll, and on Windows also windll and oledll objects to load dynamic link libraries. You load libraries by accessing them as attributes of these objects. cdll loads libraries which export functions using the standard cdecl calling convention, while windll libraries call functions using the stdcall calling convention. oledll also uses the stdcall calling convention, and assumes the functions return a Windows HRESULT error code. Here are some examples for Windows, note that msvcrt is the MS standard C library containing most standard C functions, and uses the cdecl calling convention: Windows appends the usual '.dll' file suffix automatically. Functions are accessed as attributes of dll objects:

Graphviz mediawiki-parser/parsers.rst at master · erikrose/mediawiki-parser How not to write Python code » Ikke’s blog Lately I’ve been reading some rather unclean Python code. Maybe this is mainly because the author(s) of the code had no in-depth knowledge of the Python language itself, the ‘platform’ delivered with cPython,… Here’s a list of some of the mistakes you should really try to avoid when writing Python code: Some days ago RealNitro pointed me at this list of essential Python readings. “Idiomatic Python” is a must-read, even for experienced Python developers. That’s about it for now, maybe I’ll add some more items to this list later on. Posted in Development, Technology. Tagged with Development, python. By Nicolas – February 8, 2008

PyCON FR 9.8. functools — Higher-order functions and operations on callable objects — Python v2.7.2 documentation Source code: Lib/functools.py The functools module is for higher-order functions: functions that act on or return other functions. In general, any callable object can be treated as a function for the purposes of this module. The functools module defines the following functions: functools.cmp_to_key(func) Transform an old-style comparison function to a key function. A comparison function is any callable that accept two arguments, compares them, and returns a negative number for less-than, zero for equality, or a positive number for greater-than. Example: sorted(iterable, key=cmp_to_key(locale.strcoll)) # locale-aware sort order For sorting examples and a brief sorting tutorial, see Sorting HOW TO. functools.total_ordering(cls) Given a class defining one or more rich comparison ordering methods, this class decorator supplies the rest. The class must define one of __lt__(), __le__(), __gt__(), or __ge__(). For example: functools.reduce(function, iterable[, initializer]) partial.func partial.args

javascript game of tron in 219 bytes With some coworkers, we challenged each other to write the smallest possible game of tron in javascript (an exercise known as javascript golfing). This page explains our final version (219 bytes). We initially worked alone but then exchanged ideas and tricks, so erling & mathewsb deserve most of the credits! our code was originally 226 bytes, but "Cosmologicon" pointed out a way to save three whole bytes, bringing us to 223 bytes. With p01, we then came up with a way to save another 11 bytes (making the game 212 bytes). skrounge found a way to save 2 more bytes, bringing the game to 219 bytes. Danny Loo sent me this piece of art. The entire code, with only a few extra newlines for readability. By assigning an id to the body, we are going to be able to write b.innerHTML="game over", instead of having to write document.body.innerHTML="game over"*. We can also drop the quotes around the attribute, since browsers are able to fix that for us. e is going to contain the keyboard event.

Related: