[New-bugs-announce] [issue4447] exec inside a function

David M. Beazley report at bugs.python.org
Thu Nov 27 18:35:02 CET 2008


New submission from David M. Beazley <beazley at users.sourceforge.net>:

Is the following code valid Python 3 or not?

def foo():
    x = 1
    exec("x = 42")
    print(x)    # Prints 1  (exec has no effect)

I know there are a variety of issues surrounding exec(), function 
bodies, and other matters.   Just wondering if this sort of thing is now 
forbidden or not.

----------
components: Interpreter Core
messages: 76508
nosy: beazley
severity: normal
status: open
title: exec inside a function
type: behavior
versions: Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4447>
_______________________________________


More information about the New-bugs-announce mailing list