CodeStyle » History » Version 28
Alex Afanasyev, 04/25/2014 09:23 AM
1 | 1 | Junxiao Shi | # NFD code style guidelines |
---|---|---|---|
2 | |||
3 | 27 | Alex Afanasyev | ## C++ code style |
4 | 26 | Alex Afanasyev | |
5 | 28 | Alex Afanasyev | NFD adopts [ndn-cxx code style](http://named-data.net/doc/ndn-cxx/current/code-style.html) |
6 | 19 | Alex Afanasyev | |
7 | ## Python addition |
||
8 | |||
9 | Most of the provisions in the above style guidance apply to Python as well. For python-specific elements, [PEP 8](http://legacy.python.org/dev/peps/pep-0008/) can be used as a reference coding style. |
||
10 | |||
11 | 1 | Junxiao Shi | The following is few rules directly adopted from [PEP 8](http://legacy.python.org/dev/peps/pep-0008/): |
12 | |||
13 | * **P1** Always surround these binary operators with a single space on either side: assignment (=), augmented assignment (+=, -= etc.), comparisons (==, <, >, !=, <>, <=, >=, in, not in, is, is not), Booleans (and, or, not). |
||
14 | |||
15 | def complex(real, imag=0.0): |
||
16 | value = 1.1 |
||
17 | return magic(r=real + value, i=imag) |
||
18 | |||
19 | * **P2** Don't use spaces around the = sign when used to indicate a keyword argument or a default parameter value. |
||
20 | |||
21 | def complex(real, imag=0.0): |
||
22 | return magic(r=real, i=imag) |