Skip to content

Instantly share code, notes, and snippets.

@smugen
Created December 14, 2012 16:50
Show Gist options
  • Save smugen/4286845 to your computer and use it in GitHub Desktop.
Save smugen/4286845 to your computer and use it in GitHub Desktop.
Python import cache test
import b, c
print __name__, ":", c.msg
print __name__, ":", c is b.c
print __name__, ":", "reload c"
reload(c)
print __name__, ":", c.msg
print __name__, ":", c is b.c
print __name__, ":", b.c.msg
print __name__, "enter"
import c
print __name__, ":", c.msg
c.msg = "I say B!"
print __name__, "exit"
print __name__, "enter"
msg = "I am C."
print __name__, "exit"
@smugen
Copy link
Author

smugen commented Dec 14, 2012

execute

python a.py

output

b enter
c enter
c exit
b : I am C.
b exit
__main__ : I say B!
__main__ : True
__main__ : reload c
c enter
c exit
__main__ : I am C.
__main__ : True
__main__ : I am C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment