Version 2 (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.

e.g. for

 '''some stuff about module '''
  def exitNicely(msg):
     print __doc__
     print msg
  • 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
   d]) # or
 a=(b c
 a = ('the cat '
     'sat '
     'on the mat')

This is nice too:

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

And this is an abomination:

y = (x>10) and 5 or 7

will make y 5 if x>10 ...