-
-
Save jleedev/717584 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import b | |
test1 = 'a' | |
test2 = None | |
test3 = '3' | |
if __name__ == '__main__': | |
print test1, test2, test3 #prints 'a', None, 3 | |
b.changeVars() | |
print test1, test2, test3 #prints 'a', None, 3 (i.e. nothing has changed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
a = sys.modules['__main__'] | |
def changeVars(): | |
print a.test1, a.test2, a.test3 #prints 'a', None, 3 | |
a.test1 = 'NEW VAR 1' | |
a.test2 = 'NEW VAR 2' | |
a.test3 = 'NEW VAR 3' | |
print a.test1, a.test2, a.test3 #prints 'NEW VAR 1', 'NEW VAR 2', 'NEW VAR 3' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment