Well written open source Python apps

dave.brueck at gmail.com dave.brueck at gmail.com
Mon Oct 17 14:15:16 EDT 2005


Steve M wrote:
> Here is an article discussing the coding style of BitTorrent.
>
> http://www.onlamp.com/pub/a/python/2003/7/17/pythonnews.html
>
> Maybe that code is worth looking at.

[didn't read this thread or that article until I saw the summary in Dr.
Dobb's Python-URL]

FWIW, the BitTorrent code seemed like an incredible hack to me. The
above article tries to put a positive spin on it, but seriously, the
code was a mess. Hats off to Mr. Cohen for creating BitTorrent in the
first place, but I wouldn't go looking at that code for any "best
practices".

It took several days of head scratching to figure out what was really
going on because the code is almost *completely* devoid of comments -
even high level stuff like "this module is for X" or "this class does
Y", not to mention comments to clarify code that was obscure or trying
to be too cute.

A day or so into it I discovered that there were two different public
classes with the exact same name, so anytime you saw it used elsewhere
you had to dig around to figure out which class was being used.

There were also lots of more subjective things that were pretty
annoying - state was passed around in various dictionaries (they were
begging to be refactored into classes), a lot of the variable names
seemed like misnomers, values were passed out from functions via 1-item
lists, etc. - drove me nuts. :)

To be clear, I'm not trying to rag on BitTorrent, just pointing out
that it is probably not at all what the OP is looking for (well-written
Python, stuff that is generally considered "very Pythonic").

-Dave




More information about the Python-list mailing list