Skip to main content

Load a Jupyter Notebook as a module object.

Project description

nb_as_module

pip install nb_as_module

Load a Jupyter Notebook as a module object.

from nb_as_module import nb_as_module

my_module = nb_as_module('path/to/notebook.ipynb', name='my_module')

my_module.hello()  # where `hello` is a function defined in the notebook.

Google Colab

There is also a helper module for Google Colab.

To install in Google Colab, run in a cell: !pip install nb_as_module

import nb_as_module.colab

# Mount Google Drive, where Colab notebooks are saved.
# (Note you will be asked permission for access here.)
nb_as_module.colab.mount_drive()

# Get a list of your notebooks:
list_of_notebooks = nb_as_module.colab.list_nbs()
print(list_of_notebooks)
#> ['hello.ipynb', ...]

# Load one of the notebooks in the list as a module:
hello = nb_as_module.colab.as_module('hello.ipynb', 'hello')

# Run a function from the module.
hello.hello()
#> Hello, world.

doc

Put <!--docstring--> at the beggining of markdown cells, to use them as __doc__ documentation. (If multiple cells are used, they will be concatenated.)

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

nb_as_module-0.2.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

nb_as_module-0.2.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file nb_as_module-0.2.2.tar.gz.

File metadata

  • Download URL: nb_as_module-0.2.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

File hashes

Hashes for nb_as_module-0.2.2.tar.gz
Algorithm Hash digest
SHA256 74cdf1cd77d4b32784cddda4df99818c1a839490be4784eee9a24da502dd9346
MD5 0619f3251e6d3cd14884f9caa18afcbe
BLAKE2b-256 b6873b410efb4b0f97c395f74525c67a765d7c6ebc13eca16db2e607c958ba45

See more details on using hashes here.

File details

Details for the file nb_as_module-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: nb_as_module-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

File hashes

Hashes for nb_as_module-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 88641a6b437243bbdb7ec31c4984b1d963d25d3d54419f15bdb16b00b3cb697f
MD5 8b7ddf9862868ba99b60f204c8068e20
BLAKE2b-256 6866f93255383f7829654a575f3b2fe9f9c895e940228d2cb25c5073ab1f7bc8

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