File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
22"""
3- A module to change reload() so that it acts recursively.
4- To enable it type::
3+ Provides a reload() function that acts recursively.
54
6- import __builtin__, deepreload
7- __builtin__.reload = deepreload.reload
5+ Python's normal :func:`python:reload` function only reloads the module that it's
6+ passed. The :func:`reload` function in this module also reloads everything
7+ imported from that module, which is useful when you're changing files deep
8+ inside a package.
9+
10+ To use this as your default reload function, type this for Python 2::
811
9- You can then disable it with::
12+ import __builtin__
13+ from IPython.lib import deepreload
14+ __builtin__.reload = deepreload.reload
1015
11- __builtin__.reload = deepreload.original_reload
16+ Or this for Python 3::
1217
13- Alternatively, you can add a dreload builtin alongside normal reload with::
18+ import builtins
19+ from IPython.lib import deepreload
20+ builtins.reload = deepreload.reload
1421
15- __builtin__.dreload = deepreload.reload
22+ A reference to the original :func:`python:reload` is stored in this module as
23+ :data:`original_reload`, so you can restore it later.
1624
1725This code is almost entirely based on knee.py, which is a Python
1826re-implementation of hierarchical module import.
You can’t perform that action at this time.
0 commit comments