summaryrefslogtreecommitdiffstats
path: root/HACKING
blob: 342c5bee842bfc7a10e974fe0f4e611c2e35bd7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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 80 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

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)
    * 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.