wiki:CodingStandard

Version 1 (modified by lawrence, 13 years ago) (diff)

--

Python Coding Standards for NDG

In all scripts we should make the best use of module level doc strings.

module.py

some stuff about module

def exitNicely(msg):

print doc print msg sys.exit()

  • All classes should start with a capital
  • All methods and functions should not start with a capital
  • packages should not start with a capital
  • use CamelCase for anything that is exposed ...
  • methods with intent local should be ._blah
  • methods to be not exposed should be .blah (recognising that subclasses would not be able to use blah).
  • all methods should have a docstring
  • we will use epydoc

Usefile ideas:

For line length:

 a=b+c+d # or
 a=''.join([b,c
   d]) # or
 a=(b c
    d)
 a = ('the cat '
     'sat '
     'on the mat')

This is nice too:

print >> sys.stderr,stuff goes to error ...