Notable Features of Pythonby V James Powell (vpowell at gmail dot com)
Covers some of the more notable features of Python: functional programming basics, as well as decorators, iterators and generators, and context managers. Discussion of where and why these features are useful, motivated by simple examples of real-world uses. Focuses on Python 2.7< but includes brief mention of relevant changes in Python 3000.
- functions are "first-class citizens" what does this mean? how does this allow us to write better code? what "patterns" does this eliminate? what common patterns/idioms are there?
- functions, objects, and callables what are functions under the hood? what is a callable? what are the various ad hoc protocols?
- function decorators & class decorators where might these be useful? where do these show up in the standard library? what is a function decorator? what is a decorator-generating function? what's going on under the hood?
- iterators how does a for-loop work? how do iterators work on standard data types? how do I define my own iterators? how can I define my own tuple unpacking?
- generators what is a generator? how do generators relate to comprehensions? what other things can be done with `yield` (e.g., coroutines)?
- context managers where are these useful? what commonly used context managers are available? how do I write one myself (using a class, using a generator?)