An Abridged Python Tutorial

Michael Spencer mahs at telcopartners.com
Thu Mar 24 17:37:29 CET 2005


An Abridged Python Tutorial

There are tips for the novice and tricks
that will add to your programming kicks.
     But the cardinal rule
     that you must learn at school
is that spaces and tabs never mix.

If there's syntax you don't understand,
assistance is always at hand:
     a glance at the cookbook,
     or even a quick look
at the manual should meet the demand.

If you code without reading this doc,
you may find yourself in for a shock,
     due to Python's aversion
     to boundless recursion
or the global interpreter lock.

The immutable types, such as int,
can be subclassed, but follow this hint:
     you must override __new__
     'cause __init__ does not do -
if you try it you'll find that it didn't.

Now that functional style is passe,
filter, map and reduce go away.
     Better use comprehensions
     to convey your intentions
(or itertools.chain is OK).

If today's Python code doesn't suit ya,
don't despair or attack your computer.
     If the time machine's on,
     then your problem's soon gone:
just import what you need from the __future__.

When you harbour a yen to invent,
then a PEP should ideally be sent.
     But know this in advance
     your idea has no chance
should the BDFL not consent

If you find this account is amiss,
please avoid the temptation to hiss.
     Simply offer a patch,
     to apply with dispatch
and if you seek Zen, import this!


Michael




More information about the Python-list mailing list