CodeStyle » History » Version 30
Davide Pesavento, 02/15/2023 05:12 AM
1 | 1 | Junxiao Shi | # NFD code style guidelines |
---|---|---|---|
2 | |||
3 | 27 | Alex Afanasyev | ## C++ code style |
4 | 26 | Alex Afanasyev | |
5 | 30 | Davide Pesavento | NFD adopts the [ndn-cxx code style](https://docs.named-data.net/ndn-cxx/current/code-style.html). |
6 | 19 | Alex Afanasyev | |
7 | 29 | Davide Pesavento | ## Python code style |
8 | 19 | Alex Afanasyev | |
9 | 29 | Davide Pesavento | Most of the provisions in the above style guidance apply to Python as well. For python-specific elements, [PEP 8](https://www.python.org/dev/peps/pep-0008/) can be used as a reference coding style. |
10 | 19 | Alex Afanasyev | |
11 | 30 | Davide Pesavento | The following is few rules directly adopted from [PEP 8](https://peps.python.org/pep-0008/): |
12 | 1 | Junxiao Shi | |
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 | 30 | Davide Pesavento | ```py |
16 | def complex(real, imag=0.0): |
||
17 | value = 1.1 |
||
18 | return magic(r=real + value, i=imag) |
||
19 | ``` |
||
20 | 1 | Junxiao Shi | |
21 | 30 | Davide Pesavento | * **P2** Don't use spaces around the `=` sign when used to indicate a keyword argument or a default parameter value. |
22 | 1 | Junxiao Shi | |
23 | 30 | Davide Pesavento | ```py |
24 | def complex(real, imag=0.0): |
||
25 | return magic(r=real, i=imag) |
||
26 | ``` |