问题
As recommended in (Reloading submodules in IPython) I added
%load_ext autoreload
%autoreload 2
to my notebook and now, indeed, the modules are automatically reloaded.
Alas, I have
try: # https://docs.python.org/library/importlib.html
rala_all # reload will not reset rala_all
except NameError:
rala_all = {}
in my module. It did work before using importlib, but, with autoreload I see rala_all being reset (to an empty dictionary) every time the module is reloaded.
Is there a way to avoid this? I want rala_all to survive reload.
PS. See also autoreload kills variables.
来源:https://stackoverflow.com/questions/62204805/ipython-autoreload-kills-state