We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following piece of code
def u(): exec("a=2") print(a) u()
prints "2" with python2 but "NameError: name 'a' is not defined" with python3.
The way to have it work with both versions is:
def u(): exec("a=2") print(locals()['a']) u()
The text was updated successfully, but these errors were encountered:
More details in the discussion at http://stackoverflow.com/questions/15086040/behaviour-of-exec-function-in-python-2-and-python-3/
Sorry, something went wrong.
No branches or pull requests
The following piece of code
prints "2" with python2 but "NameError: name 'a' is not defined" with python3.
The way to have it work with both versions is:
The text was updated successfully, but these errors were encountered: