[Biopython] Print statements vs functions (Python 2 vs 3)

Dan Tomso dtomso at agbiome.com
Sat Sep 7 13:50:18 UTC 2013


Hi, Peter.

This sounds OK to me.  Regarding the overall transition to Python 3--is there some sort of master plan with phasing of all the changes?  It might be helpful to have some longer-term context on any roll out.

Best regards,
Dan Tomso



-------- Original message --------
From: Peter Cock <p.j.a.cock at googlemail.com>
Date: 09/07/2013 7:42 AM (GMT-05:00)
To: Biopython Mailing List <biopython at lists.open-bio.org>
Subject: [Biopython] Print statements vs functions (Python 2 vs 3)


Dear Biopythoneers,

As you will be aware, with our recent release of Biopython 1.62
we now officially support Python 3 for the first time (specifically
Python 3.3 - we don't recommend 3.0, 3.1 or 3.2 here), while
continuing to support Python 2 as well.

Currently all our documentation is written assuming Python 2,
but with some small changes most things can be written to
work under both variants. The most visible change is how to
print things, and that happens a lot in our examples.

I would like us to switch to using the Python 3 style print
function in our documentation (including the Tutorial and
the docstrings embedded in the code as help text).

In the simplest case, this Python 2 only code:

>>> print variable

would be changed to this using Python 3 style:

>>> print(variable)

Luckily that will also work on Python 2 as well. For more
complicated examples to use the print function under
Python 2 you must add this import line to the start of
your file:

>>> from __future__ import print_function

For example, this Python 2 only example:

>>> print "Two plus two is", 4

becomes:

>>> from __future__ import print_function # at start
>>> ...
>>> print("Two plus two is", 4)

or more elegantly,

>>> print("Two plus two is %i" % 4)

Would anyone object to us using the print function style
in the Biopython documentation?

I'm particularly keen to hear from beginners - as this
is potentially confusing.

Thanks,

Peter.
_______________________________________________
Biopython mailing list  -  Biopython at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/biopython




More information about the Biopython mailing list