[SciPy-dev] adopting Python Style Guide for classes

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


Hello,

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:
http://www.python.org/dev/peps/pep-0008/
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.

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

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

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':
http://projects.scipy.org/scipy/numpy/changeset/4144
Then, we updated both SciPy and NumPy to use CapWords for TestCase classes:
http://projects.scipy.org/scipy/numpy/changeset/4151
http://projects.scipy.org/scipy/scipy/changeset/3388
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.

Cheers,

-- 
Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/


More information about the Scipy-dev mailing list