Search code examples
jupyter-notebookipython

How can I import from another ipython-notebook?


I'd like to import a func from another ipython-notebook. Say,

common_func.ipynb has def 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?


Solution

  • 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!