-
Notifications
You must be signed in to change notification settings - Fork 9
Coding Standards
- We’re basing our coding style on Google’s Python style guide. If in doubt, use this. The PEP8 guide is also good.
- We’re releasing code under the GPL3 license.
- Use Python version 2.7 with and Django 1.3.
- The final version will be released as part of the Global Pulse platform toolkit, running on a hosted server.
- We’re building at Global Pulse using a sqlite database built into python/Django which doesn't require additional downloads to use for developing on separate machines.
- Basic bug checks: run pychecker over your code.
- We're great fans of Test Driven Development: we want to use Nose and Freshen on this project.
- First line of each .py file (except init.py) is #!/usr/bin/python2.6
- One command per line – don’t separate a line with semicolons
- Indentation: use 2 spaces per indentation level. Do not use tabs.
- Line length: maximum of 80 characters per line.
-
Comments: yes please.
-
File headers: every .py file will have a header (at the top of the file), containing:
# Author name
# Date file created in YYYY-MM-DD format
# GPL3 license boilerplate -
TODO comments: should be written as # TODO(Name:YYYY-MM-DD) which would look like
# TODO(Texas:2011-06-15) Comment text here
-
Every function will have a comment above it that includes: a doc string (“””), author, description of what the function does, what its inputs and outputs are, and the exceptions that it raises
# Author: First_Name
# Description: This method takes the file inputs from the sign in page and saves them to the database
# Inputs: firstName(string), lastName(string), age(int)
# Outputs: dbSaveSuccess(boolean)
# Exceptions: variableLengthException( the variable you are inputting is longer then the maximum length allowed by the # field # in the DB ) -
Every class will have a comment above it with a description of what the class will do.
# This class imports created a Linked In API object from the username and password it is provided.
- Class Names:** ClassName
- Class variable names:** first_name
- Methods:** get_first_name
- Constants:** CONSTANT_NAME
See the Google Python style guide (link at top of this page).