[Biopython-dev] PEP8 lower case module names?

Peter Cock p.j.a.cock at googlemail.com
Thu Sep 20 09:08:58 UTC 2012

On Sun, Sep 16, 2012 at 1:34 PM, Peter Cock <p.j.a.cock at googlemail.com> wrote:
>> I guess we need to have a little hack with the 2to3 library and
>> try defining our own custom fixer for the imports...
>> Note this case difference will slightly complicate our documentation -
>> but that is always going to be an issue for the Python 2 to 3 move.
> I've made a start at this - the easy part seems to work :)
> https://github.com/peterjc/biopython/commits/py3lower
> The hard bit will be fixing all the import lines... ;)
> Peter

Progress - but slow. I think this will work with a bit more
time spent on it.

With hindsight I'd have made more effort to try and reuse
lib2to3, but the documentation is sketchy and they do warn
it is liable to change between releases.

What I've got instead is a pattern matching script which
line-by-line spots imports & updates them, and also notes
what knock on changes must be made later in the file. It
is also aware of and updates doctest examples. e.g.

from Bio import SeqIO
record = SeqIO.read("my_chr.gbk", "genbank")


from bio import seqIO
record = seqIO.read("my_chr.gbk", "genbank")

In the process I've spotted some minor style issues and
some quote mistakes in the code base which I have
fixed on the main branch as well, e.g.

I also reformatted a few import lines to make
processing them easier - and arguably easier
to read too:

One slightly more complicated issue with lower case module
names is we get clashes in some code with existing variable
or argument names. This seems particularly common with seq,
alphabet and motif.

Most of these fixes for this are on the experimental branch.
In some cases I've opted to change the import, e.g.

from Bio import Alphabet


from Bio import Alphabet as _alphabet

This seemed simplest to avoid changing argument names in

I'll continue to work on this as time allows - right now the code
is due for a refactoring (e.g. avoid code duplication where I
handle doctests), and would benefit from some self-tests.

But the message remains: This should work :)


More information about the Biopython-dev mailing list