how to go on learning python

Alice Bevan–McGregor alice at
Tue Nov 30 16:30:09 CET 2010

Howdy Xavier!

[Apologies for the length of this; I didn't expect to write so much!]

I've been a Python programmer for many years now (having come from a 
PHP, Perl, C, and Pascal background) and I'm constantly learning new 
idioms and ways of doing things that are more "Pythonic"; cleaner, more 
efficient, or simply more beautiful.  I learn by coding, rather than by 
reading books, taking lectures, or sitting idly watching screencasts.  
I constantly try to break the problems I come up with in my head into 
smaller and smaller pieces, then write the software for those pieces in 
as elegant a method as possible.

Because of my "turtles all the way down" design philosophy, a lot of my 
spare time projects have no immediate demonstrable benefit; I code them 
for fun!  I have a folder full of hundreds of these little projects, 
the vast majority of which never see a public release.  I also collect 
little snippets of code that I come across[1] or write, and often 
experiment with performance tests[2] of small Python snippets.

Often I'll assign myself the task of doing something far outside my 
comfort zone; a recent example is writing a HTTP/1.1 web server.  I had 
no idea how to do low-level socket programming in Python, let alone how 
HTTP actually worked under-the-hood, and because my goal wasn't 
(originally) to produce a production-quality product for others it gave 
me the freedom to experiment, rewrite, and break things in as many ways 
as I wanted.  :)  I had people trying to convince me that I shouldn't 
re-invent the wheel ("just use Twisted!") though they mis-understood 
the reason for my re-invention: to learn.

It started as a toy 20-line script to dump a static HTTP/1.0 response 
on each request and has grown into a ~270 line fully HTTP/1.1 
compliant, ultra-performant multi-process HTTP server rivalling pretty 
much every other pure-Python web server I've tested.  (I still don't 
consider it production ready, though.)  Progressive enhancement as I 
came up with and implemented ideas meant that sometimes I had to 
rewrite it from scratch, but I'm quite proud of the result and have 
learned far more than I expected in the process.

While I don't necessarily study books on Python, I did reference HTTP: 
The Definitive Guide and many websites in developing that server, and I 
often use the Python Quick Reference[3] when I zone out and forget 
something basic or need to find something more advanced.

In terms of understanding how Python works, or how you can use certain 
semantics (or even better, why you'd want to!) Python Enhancement 
Proposals (PEPs) can be an invaluable resource.  For example, PEP 
318[4] defines what a decorator is, why they're useful, how they work, 
and how you can write your own.  Pretty much everything built into 
Python after Python 2.0 was first described, reasoned, and discussed in 
a PEP.

If you haven't seen this already, the Zen of Python[5] (a PEP) has many 
great guidelines.  I try to live and breathe the Zen.

So that's my story: how I learn to improve my own code.  My motto, 
"re-inventing the wheel, every time," is the short version of the 
above.  Of course, for commercial work I don't generally spend so much 
time on the nitty-gritty details; existing libraries are there for a 
reason, and, most of the time, Getting Things Done™ is more important 
than linguistic purity!  ;)

	— Alice.


More information about the Python-list mailing list