Showing content from http://pyunit.sourceforge.net/notes/reloading.py below:
import os def makeModule(modname, text): f = open("%s.py" % modname, 'w') f.write(text) f.close() ## Module 'a' defines a value makeModule('a', 'value = 1\n') ## Module 'b' imports value from 'a' makeModule('b', 'from a import value\n') import a,b assert b.value == 1 ## Change the value in 'a' makeModule('a', 'value = 2\n') ## Reload to get the changes # First have to delete the 'pyc' files, or the identical # timestamp will cause Python to not bother re-compiling try: os.unlink('a.pyc') except: pass try: os.unlink('b.pyc') except: pass reload(b) reload(a) assert a.value == 2 # The following assertion fails due to the reloading order assert b.value == 2, "b.value is actually %i" % b.value
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4