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.
(module, exclude=('sys', 'os.path', 'builtins', '__main__',
'numpy', 'numpy._globals'))
| 325 | |
| 326 | # Replacement for reload() |
| 327 | def reload(module, exclude=('sys', 'os.path', 'builtins', '__main__', |
| 328 | 'numpy', 'numpy._globals')): |
| 329 | """Recursively reload all modules used in the given module. Optionally |
| 330 | takes a list of modules to exclude from reloading. The default exclude |
| 331 | list contains sys, __main__, and __builtin__, to prevent, e.g., resetting |
| 332 | display, exception, and io hooks. |
| 333 | """ |
| 334 | global found_now |
| 335 | for i in exclude: |
| 336 | found_now[i] = 1 |
| 337 | try: |
| 338 | with replace_import_hook(deep_import_hook): |
| 339 | return deep_reload_hook(module) |
| 340 | finally: |
| 341 | found_now = {} |