如何从另一个ipython-notebook导入? [英] How can I import from another ipython-notebook?

查看:282
本文介绍了如何从另一个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屋!

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