ipython autoreload kills state

泪湿孤枕 提交于 2020-06-17 13:20:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!