def reload(module, exclude=['sys', 'os.path', '__builtin__', '__main__']):
"""Recursively reload all modules used in the given module. Optionally
takes a list of modules to exclude from reloading. The default exclude
list contains sys, __main__, and __builtin__, to prevent, e.g., resetting
display, exception, and io hooks.
"""
global found_now
for i in exclude:
found_now[i] = 1
try:
with replace_import_hook(deep_import_hook):
ret = deep_reload_hook(module)
finally:
found_now = {}
return ret
# Uncomment the following to automatically activate deep reloading whenever
# this module is imported
#__builtin__.reload = reload
评论列表
文章目录