Project

General

Profile

CodeStyle » History » Version 29

Davide Pesavento, 05/14/2020 10:56 AM

1 1 Junxiao Shi
# NFD code style guidelines
2
3 27 Alex Afanasyev
## C++ code style
4 26 Alex Afanasyev
5 29 Davide Pesavento
NFD adopts the [ndn-cxx code style](https://named-data.net/doc/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 29 Davide Pesavento
The following is few rules directly adopted from [PEP 8](https://www.python.org/dev/peps/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
        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)