IPython autoreload changes in subdirectory

后端 未结 3 1977
暗喜
暗喜 2021-01-11 11:26

I launch IPython from the main folder /project. Now if I make changes in the file /project/tests/some_module.py, the changes fail to be autoreloade

3条回答
  •  攒了一身酷
    2021-01-11 11:48

    If all you need is to reload a changed file in Python just do the following:

    from main import some_module
    ....
    reload(some_module)
    

    But if your reload purposes are really eager, you can do the following (taken from this question):

    %load_ext autoreload
    %autoreload 2
    

    The previous code will reload all changed modules every time before executing a new line.

    NOTE: You can also check dreload which does a recursive reload of a module, and %run which allows you to run any python script and load all of its data directly into the interactive namespace.

    Hope it helps,

提交回复
热议问题