在IPython中自动加载模块 [英] Autoreload of modules in IPython

查看:78
本文介绍了在IPython中自动加载模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让IPython自动重新加载所有更改的代码?在每一行在shell中执行之前,或者在特别请求它时失败。我正在使用IPython和SciPy进行大量的探索性编程,每当我更改它时,必须手动重新加载每个模块是非常痛苦的。

Is there a way to have IPython automatically reload all changed code? Either before each line is executed in the shell or failing that when it is specifically requested to. I'm doing a lot of exploratory programming using IPython and SciPy and it's quite a pain to have to manually reload each module whenever I change it.

推荐答案

修订 - 请参阅下面的Andrew_1510的答案,因为IPython已经更新。

REVISED - please see Andrew_1510's answer below, as IPython has been updated.

...

从尘土飞扬的错误报告中了解如何实现目标有点难以理解,但是:

It was a bit hard figure out how to get there from a dusty bug report, but:

它现在附带IPython!

It ships with IPython now!

import ipy_autoreload
%autoreload 2
%aimport your_mod

# %autoreload? for help

...然后每次调用 your_mod.dwim() ,它将获取最新版本。

... then every time you call your_mod.dwim(), it'll pick up the latest version.

这篇关于在IPython中自动加载模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆