Skip to content
Caleb Callaway edited this page Oct 27, 2013 · 8 revisions

Much of our code is written in Python, for which there is a standard style guide. This style guide is the authoritative source of style information for our Python code, except where noted below.

Variable Names

In general, use variables that are appropriate length and to the point. Avoid abbreviation and acronyms, except extremely common ones such as "WWW".

For Python, use PEP8 naming conventions. Specific examples: module_name, package_name, ClassName, method_name, ExceptionName, function_name, GLOBAL_CONSTANT_NAME, global_var_name, instance_var_name, function_parameter_name, local_var_name.

All CSS names must be lower-case, words separated by hyphens. Example: "error-message"

Names to avoid:

  • single character names except for counters or iterators
  • dashes (-) in any package/module name
  • _double_leading_and_trailing_underscore_ names

Curly Brace Style

Not applicable to Python.

For CSS, the opening brace is preceded by a space but not a newline, and the ending brace must be have the same indent level as the scope's identifier. For example:

.error-message {
	//contents
}

Function Order

See Class Member order.

Class Member Order

  1. "Constants" and public variables
  2. Public API
  3. Internal/"private" functions, main functions (see http://docs.python.org/2/tutorial/classes.html#private-variables-and-class-local-references)

White Space

In Python, indent code blocks with 4 spaces, in accordance with the PEP 8 standard. In CSS and HTML, indent with tabs.

Comments

For Python, see http://www.python.org/dev/peps/pep-0008/#id20, excepting the rule regarding two spaces after a period.

Use comments in CSS sparingly.

The programmer is encouraged to provide URL references to any code blocks, routines, or algorithms copied or adapted from an online source such as Stack Overflow.

Clone this wiki locally