-
Notifications
You must be signed in to change notification settings - Fork 135
RAVEN Software Coding Standard
RAVEN follows the Chromium coding standard for Python code (see https://www.chromium.org/chromium-os/python-style-guidelines). Among the several rules, RAVEN strictly enforces the following:
-
Use 2 spaces for each indent level.
-
Class names should start with a Capital letter.
-
Other variables should be camelBack case. (The test system uses PEP 8 for variable naming.)
-
Private variables start with two underscores:
__
-
Protected variables should start with one underscore:
_
-
Function definitions should have at least one line of white-space afterwards.
-
except:
with no exception must never be used -
The so-called "wild importing" approach is FORBIDDEN, i.e. :
from aModule import *
- Multiple statements on one line are not allowed. For example the following is forbidden:
if makeAnimal: self.raiseAMessage("we just increased the MOOSE herd population")
and should be changed to:
if makeAnimal:
self.raiseAMessage("we just increased the MOOSE herd population")
- Tuple unpacking and packing should only be used when needed. For example:
a, b = 0, 1
should be rewritten to be:
a = 0
b = 1
However, using it for function returns and swapping is allowed, since it saves temporary variables:
a, b = b, a
or:
a, b = funct()
are allowed.
- Lines longer than 120 characters must be split.