如何从另一个 ipython-notebook 导入? [英] How can I import from another ipython-notebook?
问题描述
我想从另一个 ipython-notebook 导入一个 func.说,
I'd like to import a func from another ipython-notebook. Say,
common_func.ipnb
有 def func_a()
当我创建一个新笔记本时,如何访问来自另一个笔记本但位于同一文件夹和同一 ipython 实例中的 func_a
?
When I create a new notebook, how can I access the func_a
which is from another notebook but in the same folder and same ipython instance?
推荐答案
在 IPython 邮件列表中最近讨论了这个问题,请参阅 此处.最后(这里),找到了一个示例笔记本,它显示了一种从其他笔记本导入代码的方法.这个笔记本可以在 examples/notebooks
目录中找到,看起来像 这个.您只需"定义 NotebookLoader 和 NotebookFinder 类,如笔记本中所示.我已经尝试过 IPython 1.1.0,它运行良好!
In the IPython mailing list this was discussed very recently, see here. Finally (here), an example notebook was found, which shows a way to import code from other notebooks. This notebook can be found in the examples/notebooks
directory, and looks like this. You 'just' have to define the NotebookLoader and NotebookFinder classes as shown in the notebook. I've tried with IPython 1.1.0 and it works fine!
这篇关于如何从另一个 ipython-notebook 导入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!