How do you develop in Python?
Jesper
jlohr at post9.tele.dk
Mon Jun 11 12:02:09 EDT 2001
Don't know if it is any help but I found this on Useless Python
(http://www.lowerstandard.com/python/index.html). I have not tried it
so I can not tell you if it works as described but it looks
straightforward (on second thought I guess it won't work with 'from
module import *'. Oh well -- can´t get it all):
reloadall.py:
import types
def status(module):
print 'reloading', module.__name__
def transitive_reload(module, visited):
if not visited.has_key(module): # trap cycles, dups
status(module) # reload this module
reload(module) # and visit children
visited[module] = None
for attrobj in module.__dict__.values(): # for all attrs
if type(attrobj) == types.ModuleType: # recur if module
transitive_reload(attrobj, visited)
def reload_all(*args):
visited = {}
for arg in args:
if type(arg) == types.ModuleType:
transitive_reload(arg, visited)
if __name__ == '__main__':
import reloadall # test code: reload myself
reload_all(reloadall) # should reload this, types
More information about the Python-list
mailing list