如何从另一个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()
当我创建一个新的笔记本时,如何访问来自另一台笔记本的 func_a
相同的文件夹和相同的ipython实例?
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?
谢谢!
推荐答案
In最近讨论过的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屋!