[Biopython-dev] Python 2 and 3 migration thoughts

Eric Talevich eric.talevich at gmail.com
Sat Sep 7 19:17:08 UTC 2013


On Sat, Sep 7, 2013 at 4:30 AM, Peter Cock <p.j.a.cock at googlemail.com>wrote:

> On Fri, Sep 6, 2013 at 4:44 PM, Peter Cock <p.j.a.cock at googlemail.com>
> wrote:
> >
> > This branch is trying out marking individual Python files
> > as dual coding (Python 2 and Python 3) or as Python 2
> > only requiring conversion via 2to3 for use on Python 3:
> >
> > https://github.com/peterjc/biopython/tree/tag2to3
> >
> > Currently the tags are two special hash comment lines
> > expected near the start of the file itself (rather than a
> > list within the do2to3.py script). The actual text of the
> > marker isn't critical - perhaps these need full stops?
> >
> > # This file targets both Python 2 and Python 3 at the same time
> > # TODO - Targets Python 2 only (use 2to3 to run under Python 3)
> >
>
[...]

> > As of right now, on this branch there are only 8 files under
> > Tests which require conversion via 2to3 :
>
> Down to six files under Tests now if I rebase the branch
> to include the recent fixes on the master.
>
> > Having I hope demonstrated this will work, I'd like some
> > feedback before applying this (or a modified version of
> > it) to the master branch.
>
> I've started applying individual code fixes to the master
> to improve Python 2 and 3 compatibility already.
>
> I'm specifically looking for thoughts on how to handle
> the transition period when some of our code will still
> need 2to3, while other code will not.
>
> Does the special comment line seem like a good solution?
> On the plus side, it tracks any changes with the file being
> updated (which wouldn't happen with a list in the do2to3.py
> file).
>
> Peter
>
>
Hi Peter,

This looks like a good way to move forward overall. Regarding the special
comment  lines -- since these are only used in do2to3.py, would it be
cleaner to keep a hard-coded list of filenames in do2to3.py and leave the
modules and scripts alone? Are there any characteristics that would make it
difficult to determine whether a given module or script is Py3-compliant?

-Eric



More information about the Biopython-dev mailing list