[SciPy-dev] adopting Python Style Guide for classes

Jarrod Millman millman@berkeley....
Tue Oct 2 12:24:56 CDT 2007


For those of you not on the Numpy developer's list, we have been
talking about adopting the Python class naming convention to conform
with Guido's style guide as closely as possible:
According to Guido,  class names should use the CapWords convention.
Most Python projects (eg, ETS, matploltlib) adhere to the Python
naming conventions and it is confusing that NumPy and SciPy don't.

Currently, both NumPy and SciPy use either lower_underscore_separated
or CapWords for class names.

$ grep -r '^class [A-Z]' --include "*.py" * | wc -l
$ grep -r  '^class' --include "*.py" * | grep -v 'class [A-Z]' | wc -l

$ grep -r '^class [A-Z]' --include "*.py" * | wc -l
$ grep -r  '^class' --include "*.py" * | grep -v 'class [A-Z]' | wc -l

So far, there is Universal support for the basic idea of conforming to
the Python Style Guide.  Since it should effect the user API, we have
already updated the TestCase classes.  First, we checked in a change
to allow TestCase classes to be prefixed with
either 'test' or 'Test':
Then, we updated both SciPy and NumPy to use CapWords for TestCase classes:
In order to run the SciPy tests on the trunk you will need to install
NumPy from svn revision 4144 or greater.  Before SciPy 0.7.0 is
released, we will release NumPy 1.0.4.

Also, if you are adding a new class to NumPy or SciPy, please use
CapWords.  Now we need to decide what to do about the remaining
lower_underscore_separated class names.  Obviously, it is important
that we are careful to not break a lot of code just to bring our class
names up to standards.


Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014

More information about the Scipy-dev mailing list