[Biopython-dev] Python 2 and 3 migration thoughts

Eric Talevich eric.talevich at gmail.com
Sat Nov 2 18:23:31 UTC 2013

On Sat, Nov 2, 2013 at 10:51 AM, Peter Cock <p.j.a.cock at googlemail.com>wrote:

> On Sat, Nov 2, 2013 at 2:39 PM, Peter Cock wrote:
> > On Sat, Oct 26, 2013 at 7:44 PM, Peter Cock wrote:
> >>
> >> A new pull request for people to comment on, which eliminates
> >> all but two important fixers. As a bonus this makes installation
> >> under Python 3 much much quicker:
> >>
> >> https://github.com/biopython/biopython/pull/250
> https://github.com/peterjc/biopython/tree/py3fixes
> > I take it there are no objections to me merging this work?
> > If not, I will try to do it tomorrow (Sunday) or early next week,
> > and move on to the final issues before we can drop 2to3
> > (which I do not anticipate being problematic).
> They are not troublesome, perhaps worth applying soon too?
> (Can anyone propose a more elegant solution to __nonzero__
> versus __bool__ than to just define both?)
> This allows us to stop using 2to3 (something NumPy have
> also managed in their recent NumPy 1.8 release), making
> installation of Biopython from source under Python 3.3
> faster and much simpler:
> https://github.com/peterjc/biopython/tree/py3more
> Regards,
> Peter

Cool, no objections here. Maybe after the next stable release we can look
into finalizing and merging the new GSoC work?

As far as I can tell the best way to handle __nonzero__ vs. __bool__ is
what you indicated:

class Foo(object):
    def __bool__(self): return True
    __nonzero__ = __bool__

And presumably the 2to3 converter would need to be disabled at the same
time, or it might try to rename __nonzero__ to __bool__ and get confused.


More information about the Biopython-dev mailing list