Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Conventions in CherryPy Coding Style

CherryPy is an open source project. It means that all developers can contribute, but also, that everyone is responsible for the coding standards. To keep the source code in a consistent state, and to make sure that all tools work nicely, some guidelines must be adhered to:

  • Source code must be indented with 4 spaces, no tabs.
  • Source files must use Unix-style LF line termination. This is required to avoid problems when using tools such as Subversion, which wrongly think that the entire file has changed if the line ends change. Set svn:eol-style to 'native'.
  • Source code must be kept less than 79 columns wide, whenever possible. Common sense should apply; sometimes it's acceptable to have a slightly longer, but more readable, line.
  • CherryPy code should follow PEP 8 wherever possible. This includes CapWords for class names and lower_with_underscores for function names and everything else. If an identifier includes acronyms such as URL, HTTP, or HTML, those should be included as ALLCAPS.
  • Top-level modules which are for internal use only (by the CherryPy core) should have names starting with _cp. Module names should never contain internal underscores. See PackageStrategy for more information on module naming and heirarchy guidelines.
  • Order of imports: Imports should happen alphabetically, first with imports from the standard library, then a blank line, then imports from internal modules. Example:
import email
import socket
from time import time

import my_internal_module
from my_other_module import bar

Hosted by WebFaction

Log in as guest/cpguest to create tickets