[IPython-dev] future division in embedded ipython
Thomas Kluyver
takowl at gmail.com
Wed Jul 4 13:19:00 EDT 2012
On 4 July 2012 17:59, Carl Smith <carl.input at gmail.com> wrote:
> It'd be nice to have some way of making this work as you presume it will.
> Even if it's caused by a misunderstanding of Python by the user, it's still
> just buggy from a UX perspective.
I wouldn't say it's a misunderstanding, it's just not clear what
behaviour is correct. future statements don't normally affect code
beyond the module where they're imported. The closest concept to
IPython's embedding in standard Python is to launch a debugger - and
future statements in the module don't hold in the debugger (I've just
checked).
If we do agree that propagating future flags to embedded IPython is
what we want, I think it should be possible using sys._getframe().
What's more complex is how it should interact with future statements
you enter yourself in the interpreter. It can't change the future
flags for the module, because that's already been parsed. But if you
embed multiple times, should your changes to __future__ in the first
embedding be kept for the second?
Thanks,
Thomas
More information about the IPython-dev
mailing list