Skip to main content

Small Python utility for importing functions, classes, and constants from .ipynb files.

Project description

Small Python utility for importing functions, classes, and constants from .ipynb files. A few other packages offer to provide similar functionality; I wrote this because none of them worked on the first try for me.

Notebooks can be imported from other notebooks or from normal Python scripts. The target notebook is assumed to be located in the current working directory.

You just import the notebook as if it was a submodule of from_notebook. So to import definitions from example.ipynb, any of the following will work:

import from_notebook.example

import from_notebook.example as example

from from_notebook.example import example_function, ExampleClass

No notebook code is executed except for imports, class and def statements, and SNAKE_CAPS = ... assignments. All of these will be executed, so make sure they don’t set off any unwanted side effects.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

from_notebook-0.0.1.tar.gz (1.5 kB view hashes)

Uploaded Source

Built Distribution

from_notebook-0.0.1-py3-none-any.whl (2.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page