[IPython-dev] Doctests & Python 3
Tue Aug 23 17:38:07 CDT 2011
Ah, I didn't realize you used doctests like that. I'd recommend
writing a program that runs 2to3 on the IPython doctests rather than
rewriting the regular expressions yourself.
On Tue, Aug 23, 2011 at 4:24 PM, Thomas Kluyver <firstname.lastname@example.org> wrote:
> On 23 August 2011 22:33, Aaron Meurer <email@example.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 :" 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).
More information about the IPython-dev