Skip to main content

Simply returns either notebook filename or the full path to the notebook when run from Jupyter notebook in browser.

Project description

nci_ipynb

This work was inspired from ipynbname.

When run in a Jupyter notebook, simply returns the notebook filename or the full path to the notebook. I created this to help with automating posting blog posts written in Jupyter notebooks directly to GitHub Pages.

You would think there was already some built-in way to access the current notebook name, but it took many hours of searching for a way to do it. As it seems many others did, I tried using Javascript, but the async nature of JS meant that it was unreliable. Finally I stumbled on this post. I have refactored the code there so a user can get either the name or path, but credit for most of the code goes to the author of this post, thanks!

Examples

Get the notebook name:

import nci_ipynb
nb_fname = nci_ipynb.name()

Get the full path to the notebook:

import nci_ipynb
nb_path = nci_ipynb.path()

Get the root directory to the notebook:

import nci_ipynb
nb_path = nci_ipynb.dir()

Limitations

Note that this only reliably works when running a notebook in a browser. So it does not currently work for things like nbconvert or papermill.

For VS Code there is a workaround.

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

nci_ipynb-2023.11.0.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nci_ipynb-2023.11.0.3-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file nci_ipynb-2023.11.0.3.tar.gz.

File metadata

  • Download URL: nci_ipynb-2023.11.0.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.8

File hashes

Hashes for nci_ipynb-2023.11.0.3.tar.gz
Algorithm Hash digest
SHA256 656963dc1e5a6fad1e8d863e336ba7c6066250387822ddcd94e7e61b55c1e43c
MD5 3325060eb0e881602c4227ce7739165a
BLAKE2b-256 851b2451e64d5f3310a7649fd9093f123f1a9604011c9baae065c7f0af72cd04

See more details on using hashes here.

File details

Details for the file nci_ipynb-2023.11.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for nci_ipynb-2023.11.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7b4d916568308b89c7efd6bd8fc1abe601511a1c521cec7ca3b9b33019813568
MD5 75a7c2d3968a8cd528bd1cd9e1dfb5cb
BLAKE2b-256 97ac32afd602d3fd8cd001d910747c7953c37c82cb564aeddcf40f027c057a60

See more details on using hashes here.

Supported by

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