My favorites | Sign in
Google
                
Search
for
Updated Jun 23, 2009 by j...@google.com
Labels: Phase-Implementation, Style
StyleGuide  
Coding style guide for project contributors.

Introduction

Additions and modifications to the code in this project should conform to these style guidelines.

Rules

Naming conventions

Type Public Internal
Packages lower_with_under
Modules lower_with_under _lower_with_under
Classes CapWords _CapWords
Exceptions CapWords
Functions CapWords(), lower_with_under() _CapWords(), _lower_with_under()
Global/Class Constants CAPS_WITH_UNDER _CAPS_WITH_UNDER
Global/Class Variables lower_with_under _lower_with_under
Instance Variables lower_with_under _lower_with_under (protected) or __lower_with_under (private)
Method Names CapWords(), lower_with_under() _CapWords(), _lower_with_under() (protected) or __CapWords(), __lower_with_under() (private)
Setter/Getter Method Names foo(), set_foo()
Function/Method Parameters lower_with_under
Local Variables lower_with_under

Imports

Always import modules explicitly - never use from x import *, instead use

from x import y
from x import z
import w

Global Variables

Global (module visible) variables should only be used for constants.

Default Argument Values

Feel free to use them in accordance with the following guidelines

Line Length

80 characters

Blank Lines

1 blank line between methods within a class, between the docstring and code and within a method to break the instructions into logical sections.

2 blank lines between top level definitions.

For example

import xyz


class Foo(object):
  def __init__(self):
    pass

  def do_something(self):
    pass


def module_function():
  return 'ok'


if __name__ == '__main__':
  print 'Running this module as a script.'

Unit Tests

Bug fixes and new modules should be accompanied with test cases in the appropriate test modules. The test module directory structure mirrors that of the src directory. For example, unit tests for the gdata.data module live in tests/gdata_tests/data_test.py. If you have written a new module, you can speed up the process of writing you unit tests by using one of the available CodeTemplates.


Comment by nickle, Feb 08, 2009

It might be a good idea publishing a list of PyLint? command line options for the code to be checked against


Sign in to add a comment