[Python-Dev] __future__ and the interactive interpreter prompt
Guido van Rossum
guido@digicool.com
Thu, 01 Mar 2001 13:34:53 -0500
> from __future__ import nested_scopes is accepted at the interactive
> interpreter prompt but has no effect beyond the line on which it was
> entered. You could use it with lambdas entered following a
> semicolon, I guess.
>
> I would rather see the future statement take effect for the remained
> of the interactive interpreter session. I have included a first-cut
> patch below that makes this possible, using an object called
> PySessionState. (I don't like the name, but don't have a better one;
> PyCompilerFlags?)
>
> The idea of the session state is to record information about the state
> of an interactive session that may affect compilation. The
> state object is created in PyRun_InteractiveLoop() and passed all the
> way through to PyNode_Compile().
>
> Does this seem a reasonable approach? Should I include it in the
> beta? Any name suggestions.
I'm not keen on changing the prototypes for PyNode_Compile() and
PyRun_InteractiveOne(). I suspect that folks doing funky stuff might
be calling these directly.
Would it be a great pain to add ...Ex() versions that take a session
state, and have the old versions call this with a made-up dummy
session state?
--Guido van Rossum (home page: http://www.python.org/~guido/)