2007-07-11 05:00:10 +00:00
|
|
|
|
# Copyright (c) 2006 Marcos Pinto ('markybob') <markybob@gmail.com>
|
|
|
|
|
|
|
|
|
|
This is pretty much taken straight out of PEP 8, the "Style Guide for Python
|
|
|
|
|
Code" (http://www.python.org/dev/peps/pep-0008/)
|
|
|
|
|
More or less, if you try to submit a patch that doesn't follow this guide, odds
|
|
|
|
|
are your patch will be denied...unless it does some incredibly magnificient
|
|
|
|
|
things, in which case I *might* edit it. Don't bet on it, though.
|
|
|
|
|
|
|
|
|
|
Here are the highlights:
|
|
|
|
|
Indents are FOUR (4) spaces. Not 8, not 5 or 2 and definitely NOT tab.
|
|
|
|
|
Limit all lines to a maximum of 79 characters.
|
|
|
|
|
Use UTF-8 encoding
|
|
|
|
|
Every single import should be on its own line
|
|
|
|
|
Avoid extraneous whitespace in the following situations:
|
|
|
|
|
Yes: spam(ham[1], {eggs: 2})
|
|
|
|
|
No: spam( ham[ 1 ], { eggs: 2 } )
|
|
|
|
|
Yes: spam(1)
|
|
|
|
|
No: spam (1)
|
|
|
|
|
Yes: if x == 4: print x, y; x, y = y, x
|
|
|
|
|
No: if x == 4 : print x , y ; x , y = y , x
|
|
|
|
|
Yes: dict['key'] = list[index]
|
|
|
|
|
No: dict ['key'] = list [index]
|
|
|
|
|
Yes:
|
|
|
|
|
x = 1
|
|
|
|
|
y = 2
|
|
|
|
|
long_variable = 3
|
|
|
|
|
No:
|
|
|
|
|
x = 1
|
|
|
|
|
y = 2
|
|
|
|
|
long_variable = 3
|
2007-07-18 18:56:50 +00:00
|
|
|
|
|
2007-07-21 21:40:01 +00:00
|
|
|
|
Some more recommendations:
|
|
|
|
|
* "Don’t repeat yourself (DRY). Every distinct concept and/or piece of
|
|
|
|
|
data should live in one, and only one, place. Redundancy is bad.
|
|
|
|
|
Normalization is good." (taken straight from django's Design philosophies)
|
2007-07-18 18:56:50 +00:00
|
|
|
|
* Try to use iterators/generators where applicable. The simplest change from
|
|
|
|
|
range to xrange is also good.
|
|
|
|
|
* In UI and deluge code for consistency we use notion of speed not rate.
|
|
|
|
|
Libtorrent mixes this usage and so do we on deluge-libtorrent boundary,
|
|
|
|
|
but all deluge only code should use speed.
|