code.interact() locals + globals?

I notice code.interact() in Python 2.6 has a parameter for locals but not globals. Should it? Ultimately, *exec* is used underneath so I don't see a technical reason why it couldn't add a global parameter. Also, although one could pass in a dictionary that is the merger or update() of locals() and globals(), this has a couple of downsides. First, if the intention is to allow update of local and global variables, combining the two into a single dictionary wreaks havoc. Even if one doesn't care about this, when the underlying *exec* is performed it will see different and wrong values for the functions locals() and globals() among other problems of this kind.

On Sat, Feb 21, 2009 at 15:20, Rocky Bernstein <rocky@gnu.org> wrote:
I notice code.interact() in Python 2.6 has a parameter for locals but not globals. Should it?
What is code.interact()?:: >>> (lambda: None).__code__.interact Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'code' object has no attribute 'interact' -Brett

On Sat, Feb 21, 2009 at 16:59, Brett Cannon <brett@python.org> wrote:
On Sat, Feb 21, 2009 at 15:20, Rocky Bernstein <rocky@gnu.org> wrote:
I notice code.interact() in Python 2.6 has a parameter for locals but not globals. Should it?
What is code.interact()?::
>>> (lambda: None).__code__.interact Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'code' object has no attribute 'interact'
nm, I figured out you mean the code module. -Brett
participants (2)
-
Brett Cannon
-
Rocky Bernstein