FAQ

On Sat, Sep 12, 2015 at 1:03 AM, Ian Kelly wrote:
There's also a bunch of specialised and complicated rules for what happens
if you make a star import ("from module import *") inside a function, or
call eval or exec without specifying a namespace. Both of these things are
now illegal in Python 3.
Huh?
exec("x = 42")
x
42
exec("x = 43", None, None)
x
43

That's in Python 3.4.0. Maybe I don't understand what you mean by
"without specifying a namespace".

*inside a function*

def f():
... exec("x = 42")
... print(x)
...
x = 231
f()
231


ChrisA

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

People

Translate

site design / logo © 2017 Grokbase