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.