Saturday, July 09, 2011

Stuff about Python

The stuff here should be seen in the context of CPython unless otherwise stated.

Basic
  1. "import this" easter egg
  2. the pass keyword
  3. Remember to have __init__.py to you modules. You can put code in __init__.py too! (e.g. for initializations, and functions in there can be imported)
  4. Single underscores should be used for private variables.
  5. re.match() only attempts to match a pattern at the beginning of a string where re.search() will match a pattern anywhere in a string.
  6. Readline configuration for python
  7. Else clauses on for loops (or even try-except statements)
  8. Function closures

Advanced
  1. unittest module
    There is so much magic happening behind the scenes that I recommend taking a look at the source code to understand what's going on.
  2. Design Patterns in Python
  3. More Design Patterns (slides) (from Google)
  4. Use coroutines via enhanced generators (PEP 342). A cool networking/threading library written using coroutines. More about coroutines via PFPL chp 33.3
  5. Mixins
  6. Decorators (tutorial, advanced)
  7. What you should know about exec and compile
  8. New and old classes
Implementations of Py
  • CPython
  • JPython
  • IronPython
  • StacklessPython

Note: This post is a work in progress.

No comments: