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

Peter Cock p.j.a.cock at googlemail.com
Sat Sep 7 13:52:54 UTC 2013


On Sat, Sep 7, 2013 at 12:41 PM, Peter Cock <p.j.a.cock at googlemail.com> wrote:
> 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.

I tweeted this email,

Biopython Project (@Biopython): Would anyone object to us using
#Python3 print function style in the #Biopython documentation?
http://lists.open-bio.org/pipermail/biopython/2013-September/008751.html
https://twitter.com/Biopython/status/376309705972654080

Two replies already:

Raphael Mattos (@rsmattos): @Biopython I think it's time....
https://twitter.com/rsmattos/status/376321218456338432

Alec Munro (@alecmunro): @Biopython do it!
https://twitter.com/alecmunro/status/376341224544038912

Peter



More information about the Biopython mailing list