[Biopython-dev] Print statements vs functions (Python 2 vs 3)
Peter Cock
p.j.a.cock at googlemail.com
Mon Sep 9 20:29:35 UTC 2013
On Sat, Sep 7, 2013 at 7:12 PM, Peter Cock <p.j.a.cock at googlemail.com> wrote:
> On Sat, Sep 7, 2013 at 2:52 PM, Peter Cock <p.j.a.cock at googlemail.com> wrote:
>> On Sat, Sep 7, 2013 at 12:41 PM, Peter Cock <p.j.a.cock at googlemail.com> wrote:
>>> ...
>>>
>>> Would anyone object to us using the print function style
>>> in the Biopython documentation?
>
> ...
>
> Since there has only been positive reaction, I've made a
> start at converting the examples in the Tutorial to use the
> Python 3 style print function (maintaining full Python 2
> compatibility under Python 2.6 and 2.7 via the future
> import):
>
> https://github.com/biopython/biopython/commit/34d155a02cbcf7c953fb8238a5412f8c7c0e1cc5
> https://github.com/biopython/biopython/commit/74a8b8349b58ae9aa7a727d6e1ab774a4c9008a3
>
It turned out to be slightly more than a weekend project, but
I've now done this for the main code including the doctests :)
All new code changes should be written using the print
function style and will then work on both Python 2 and 3
without change, e.g.
print(variable)
Any accidental usage of an old-style print statement
will be caught in two ways, under Python 2 via the future
import (if it is in the file you are editing):
https://github.com/biopython/biopython/commit/de12c5e08fc44d9c158954bb4b1d5f98cfb84c69
And I have also disabling the print fixer during 2to3
which would result in old-style print statements causing
an error when testing under Python 3:
https://github.com/biopython/biopython/commit/00ab061dba42082ff0e20383847ebffaf6dd8eef
If you are using a print function, and the file doesn't have
it already, please add the future import:
from __future__ import print_function
If there any any stray print statements still there (e.g.
hiding in examples scripts I missed), please fix them
or report them.
Regards,
Peter
More information about the Biopython-dev
mailing list