Style Guide/Python

Python Style Guide

Python code should adhere to PEP 8, with the following clarifications:

  • Only use four spaces for indentation, no tabs.
  • Spaces around operators (except for keyword arguments).
  • Use CamelCase for classes and exception types. Use underscore_case for everything else.


Scripts with the following comment are meant to be pep8.

# <pep8 compliant>


Exceptions to pep8

  • Line width:
    Maximum width for lines is 120 for all scripts.
    Optionally you can use shorter line width, using the comment:
    # <pep8-80 compliant>
    
  • Imports:
    We often put imports within functions body which is not pep8 compliant.
    This is done to speed up Blender's startup times to avoid loading in many files and libraries which the user may never access.


Related Topics