Proper way to reload a python module from the console

前端 未结 8 1950
迷失自我
迷失自我 2020-12-03 04:51

I\'m debugging from the python console and would like to reload a module every time I make a change so I don\'t have to exit the console and re-enter it. I\'m doing:

<
8条回答
  •  猫巷女王i
    2020-12-03 04:56

    IPython can reload modules before executing every new line:

    %load_ext autoreload
    %autoreload 2
    

    Where %autoreload 2reloads "all modules (except those excluded by %aimport) every time before executing the Python code typed."

    See the docs:

    • https://ipython.org/ipython-doc/3/config/extensions/autoreload.html

提交回复
热议问题