Skip to content

Instantly share code, notes, and snippets.

@edsu
Last active August 31, 2022 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edsu/077a4e7089c4ef3ea7de92fd9819ba71 to your computer and use it in GitHub Desktop.
Save edsu/077a4e7089c4ef3ea7de92fd9819ba71 to your computer and use it in GitHub Desktop.
globals()['y'] = 1
# this works
globals()['x'] = 1
print(x)
# this works too
import mymodule
print(mymodule.y)
# but this doesn't because y is global mymodule
print(y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment