Skip to content

Instantly share code, notes, and snippets.

@ellieayla
Created August 11, 2017 00:39
Show Gist options
  • Save ellieayla/af4fa90486f8e5ddb7bff8d444407283 to your computer and use it in GitHub Desktop.
Save ellieayla/af4fa90486f8e5ddb7bff8d444407283 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# https://www.reddit.com/r/Python/comments/6sx3xk/variable_being_treated_locally_when_should_be/
from __future__ import print_function
def Ocean(fake_argument_to_keep_the_signature_the_same):
from os import path # line 2
global path # line 6
path.ADDITIONAL = "ATTRIBUTE"
print("Ocean", path.ADDITIONAL)
def Second():
print("Second", path.ADDITIONAL)
if __name__ == "__main__":
Ocean(1)
print("__main__", path.ADDITIONAL)
Second()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment