Coding Style

If anything in this document conflicts with PEP 8 (Style Guide for Python Code) then please correct it as the PEP is leading.

General Python guidelines (PEP-8)

Project specific guidelines

General

(?) means that we haven't decided on this yet

Debugging

Don't use print statements, use the logging facility. At the top of a module, use:

from rabbitvcs.lib.log import Log
log = Log("rabbitvcs.mymodule") # Replace "mymodule", obviously

…and then, eg.

log.debug("Number of items: %i" % len(items))

…or even:

try:
    risky_thing()
except Exception, e:
    log.exception(e)

Sometimes, if you put in some code for debugging, you could even leave it in as a comment for future maintainers, eg. from the status checker code:

# Uncomment this for useful simulation of a looooong status check :) 
# log.debug("Sleeping for 10s...")
# time.sleep(5)
# log.debug("Done.")

If you use Eclipse + pydev, use task tags to remind yourself to remove or flesh things out (eg. #FIXME: simplify code after debugging)

Example

[…]