Autoreload of modules in IPython

来源:互联网 发布:wake瑜伽软件下载 编辑:程序博客网 时间:2024/06/08 15:25

ipython很好用,但是如果在ipython里已经import过的模块修改后需要重新reload就需要这样

In [1]: %load_ext autoreloadIn [2]: %autoreload 2In [3]: from foo import some_functionIn [4]: some_function()Out[4]: 42In [5]: # open foo.py in an editor and change some_function to return 43In [6]: some_function()Out[6]: 43

如果想在ipython每次启时自动加载,步骤如下
it may be necessary to generate one first:
1、运行下面的command用来产生ipython_config.py文件

ipython profile create

2、gedit ~/.ipython/profile_default/ipython_config.py添加:

c.InteractiveShellApp.exec_lines = []c.InteractiveShellApp.exec_lines.append('%load_ext autoreload')c.InteractiveShellApp.exec_lines.append('%autoreload 2')


原创粉丝点击