Skip to content

Coding Style

Man-Long Wong edited this page Jul 3, 2017 · 20 revisions

Programming language

We use Python 2 as the programming language for the core modules.

Naming convection

It is recommended to use:

  1. UpperCamelCase for class names
  2. lowerCamelCase for methods and functions
  3. CAPITALIZED_WITH_UNDERSCORES for constants
  4. lowercase_separated_by_underscores for variable names
  5. lowercase_separated_by_underscores for python file names
  6. UpperCamelCase for names of Jupyter Notebook example scripts

Indentation

4 spaces of indentation, and no tab characters should be used.

Comments

Triple quote format is preferred for docstring that appears as first statement in classes, methods or functions.

A single line above the code is recommended. Add full stop at the end of each comment.

Others

Use two empty lines between def's.

Use single underscore _private to indicate that attribute or method are for internal use in class.