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.1.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

import_ipynb-0.1.4-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: import-ipynb-0.1.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/59.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.7

File hashes

Hashes for import-ipynb-0.1.4.tar.gz
Algorithm Hash digest
SHA256 dcec6ab3ea13a3a5ccefc9a9963021706af3389775e1246d1abd7cbefc0d54a6
MD5 9ac9b437a6f797184d6b1070a99990d5
BLAKE2b-256 ac222e6356db42a17b4e774a47c6c23f3cd62532a29162d88c27135a3e676130

See more details on using hashes here.

File details

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

File metadata

  • Download URL: import_ipynb-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/59.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.7

File hashes

Hashes for import_ipynb-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 27ef4fd477fbbd89f70828c736357f991e21c06ac92b1465c7dbcf4c698fb7ab
MD5 4ace93183a80ed74e6d657342f4d99f7
BLAKE2b-256 805da94923929ac5687d4a3b83440d1f95aaed7eea4a2b05c31d76d8f5564a89

See more details on using hashes here.

Supported by

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