[IPython-dev] Doctests & Python 3

Thomas Kluyver takowl at gmail.com
Tue Aug 23 18:24:17 EDT 2011


On 23 August 2011 22:33, Aaron Meurer <asmeurer at gmail.com> wrote:

> There is a -d option to 2to3 that should do the necessary
> transformations for you.
>

Indeed, and distribute should be doing that (albeit not via a command line
flag) in the build process. But it seems like it doesn't recognise IPython
doctests (with our "In [1]:" style prompts). If anyone knows of a way to
extend it to pick that up, that would be the neatest solution, but I don't
know if it's possible.


> Also, if you don't actually use the fact that it's a function, you
> don't have to import print_function from __future__ to use the
> print(1) syntax in Python 2.
>

But print(1,2) will print a tuple, rather than "1 2". If we're going to go
down the route of using the new syntax for doctests, it should be simple
enough to use print_function. But it's not ideal to have to write all our
Python 2 doctests using Python 3 syntax (although I've already tweaked a few
minor bits, like list(range(n)) and a//b, for consistency).

Thanks,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20110823/262148a4/attachment.html>


More information about the IPython-dev mailing list