Skip to main content

Imports A.ipynb into B.ipynb

Project description

Motivation

Suppose you want to import the contents of A.ipynb into B.ipynb.

Installation

pip install import-ipynb

How to use

Place both ipynb files in the same directory. Then, in the B.ipynb:

import import_ipynb
import A

Congratulations! You can now run any functions defined in A.ipynb from B.ipynb!

How it works

The code within import_ipynb.py defines a “notebook loader” that allows you to ‘import’ other ipynb files into your current ipynb file. This entails:

  1. load the notebook document into memory

  2. create an empty Module

  3. execute every cell in the Module namespace

Note that since every cell in the A.ipynb is executed when you import the the file, A.ipynb should only contain classes and function definitions (otherwise you’ll end up loading all variables and data into memory).

Credits

The code within imoprt_ipynb.py comes from http://jupyter-notebook.readthedocs.io/en/latest/examples/Notebook/Importing%20Notebooks.html.

Riley F. Edmunds (@rileyedmunds) wrote instructions on how to use it and Lev Maximov (@axil) packaged it.

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

import-ipynb-0.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

import_ipynb-0.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file import-ipynb-0.2.tar.gz.

File metadata

  • Download URL: import-ipynb-0.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.1

File hashes

Hashes for import-ipynb-0.2.tar.gz
Algorithm Hash digest
SHA256 0a6db02db7973a35ed1bf007b837288b13374897282218e226d01a1eaecaff85
MD5 3a9fbc73cf35f33efdabc6a5be681926
BLAKE2b-256 7d5f07f93b0e5a94b69a65eb108290ae0544210affeb24ec20cf219fe60b4e8e

See more details on using hashes here.

File details

Details for the file import_ipynb-0.2-py3-none-any.whl.

File metadata

  • Download URL: import_ipynb-0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.1

File hashes

Hashes for import_ipynb-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cb9e41c65dd81ebaa8e1e3e1b591276f910fbaac9238960d6798aad28d4c323f
MD5 4275cd29783eaaeb55daa418fb73732f
BLAKE2b-256 ec62e0b830773060d2a390aa923dcc8afc680d798bdbdadb6394f760fac62517

See more details on using hashes here.

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