Comment

Comment by speedster217

I just tested it in Python3:

    def foo():
        exec("a=1")
        return a

    print(foo())
Fails with a NameError:

    Traceback (most recent call last):
      File "test.py", line 5, in <module>
        print(foo())
      File "test.py", line 3, in foo
        return a
    NameError: name 'a' is not defined

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton