[Numpy-discussion] PEP8

Charles R Harris charlesr.harris at gmail.com
Sat Sep 7 19:56:52 EDT 2013

Hi All,

I've been doing some PEP8 work using autopep8. One problem that has turned
up is that the default behavior of autopep8 is version dependent. I'd like
to put a script in numpy tools that runs autopep8 with some features
disabled, namely

   1. E226 -- puts spaces around arithmetic operators (+, -, *, /, **).
   2. E241 -- allows only single spaces after ','

The first leaves expression formatting in the hands of the coder and avoids
things like "2 ** 3". The second allows array entries to be vertically
aligned, which can be useful in clarifying the values used in tests. A few
other things that might need decisions:

   1. [:,:, 2] or [:, :, 2]
   2. Blank line before first function after class Foo():

The advantage of having a fixed script for PEP8 compliance is that once the
code is brought into compliance it will stay there and we can recommend
running the script before pushing. That will not only keep the code looking
neat and regular, but will also strip trailing whitespace. Of course, the
autopep8 folks might make further changes in the defaults that will cause
trouble in the future, but I hope that will be a minor nuisance that we can
deal with. There are options for
pep8 <https://pep8.readthedocs.org/en/latest/intro.html#error-codes> in
case folks have other suggestions for features to add or disable.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130907/a0369931/attachment.html>

More information about the NumPy-Discussion mailing list