[bip] Pylint and PEP8

Robert Kirkpatrick robertk at bcgsc.ca
Fri Jan 4 12:02:37 PST 2008


Hi Gang,

I was a noob wrt coding standards until I started using Python.  I actually
stumbled upon the PEP-8 standard in a round-about way.  I started running my
code through Pylint (http://www.logilab.org/857) and was puzzled as to where
the rules came from until I realized the rules were based on PEP-8.

I was curious to see that Pylint wasn't mentioned on bio.scipy.org site and
was wondering if this is something that would be good for us all.  Using
Pylint helped me in multiple ways (and no I have no affiliation with the
Pylint authors or their organization).  First off, it's simple to run and
very customizable.  Second, for noobs to coding (like I was/am ), it can
actually teach the biologist some basics of coding.  For instance, you run
your code through Pylint and it tells you:

W0621: 38:main: Redefining name 'version' from outer scope (line 80)
W0622: 24:main: Redefining built-in 'file'
W0311: 28: Bad indentation. Found 9 spaces, expected 8
W0704:101: Except doesn't do anything

These errors can all start the teaching process as to why those are
important and led me to understand coding theory a lot more.  I forced
someone else to run Pylint against their will and they actually liked it and
found it easy.

The second error message above is one that is mentioned in the wiki as a
"please don't do this" so Pylint could help people (and the community) to a
avoid these basic mistakes.  Many people don't even know they are using a
reserved word until it is pointed out to them.

The other nice thing about Pylint is the ability to define an rc file.  We
could "design" an rc file for scipy as a recommended minimum of rules that
must not be violated (i.e. when you run your code through Pylint, it is
quiet).

Those are my thoughts and if there is interest, I can run with this a bit
and get something on scipy akin to a code standard tutorial.

Cheers,
Rob


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rob Kirkpatrick
Genome Sciences Centre
BC Cancer Agency
Vancouver, BC V5Z 4S6
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




More information about the biology-in-python mailing list