[Biopython-dev] 2to3 and doctests

Peter biopython at maubp.freeserve.co.uk
Fri Jul 16 15:31:51 UTC 2010


2010/7/16 Tiago Antão <tiagoantao at gmail.com>:
> 2010/7/16 Peter <biopython at maubp.freeserve.co.uk>:
>> You've been looking more carefully at 2to3 and doctests than I have,
>> perhaps you can answer this query for me: It seems to me it does
>> not automatically fix doctests.
>>
>> I'm aware of the -d or --doctests_only option, but that means we have
>> to run 2to3 twice I think (once for the code, once for the doctests).
>>
>> Is there an extra flag or something obvious I am missing here? I want
>> to call 2to3 once and have it fix the code including the doctests.
>
> My assessment is exactly the same as yours.
> I call the app 2 times: one for code, another for doctests.
> The setup.py that I provided only does code precisely because of this.
> I still did not have time to, programatically, call both
> transformations.
> So: yes it sucks.

Maybe we should file an enhancement bug report?

> Talking about setup.py, its current incarnation is broken on Python 3.
> Even if the objective is for it to print some information on calling
> 2to3 it will not work. Just putting the prints with () should sort it
> (and work everywhere)

I like that plan except for a "bug" in 2to3, it will turn this example which
works for BOTH python 2 and python 3:

print("Hello world")

into this:

print(("Hello world"))

Using this syntax for simple prints is actually a tip here:
http://wiki.python.org/moin/PortingPythonToPy3k

> Anyway, I think we can make setup.py much more helpful in the p3 case
> by calling 2to3 (like numpy). The tests would also need to be
> transformed, I think.

I think its a little premature for that - but once we have a full the conversion
running smoothly it makes sense. For now transforming the code in situ
makes working in Python 3 to debug something much easier I think.

Peter




More information about the Biopython-dev mailing list