Simply returns either notebook filename or the full path to the notebook when run from Jupyter notebook in browser.
Project description
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 ipynbname
nb_fname = ipynbname.name()
Get the full path to the notebook:
import ipynbname
nb_path = ipynbname.path()
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ipynbname-2024.1.0.0.tar.gz
.
File metadata
- Download URL: ipynbname-2024.1.0.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d3c69cdee8a97814f456a7204e9cc195b4bbb4b9e45cbe757796b162493f606 |
|
MD5 | fd77ef630e029f6193f03c8bb2a76150 |
|
BLAKE2b-256 | d84ba84ceea5ff73ec0e466540d54e835414f3e0ecde8389ce008e12fa129709 |
File details
Details for the file ipynbname-2024.1.0.0-py3-none-any.whl
.
File metadata
- Download URL: ipynbname-2024.1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdd098cfe1986baa1d4ecb0b42f7a2b63646f25570f57163239beba73f26d65a |
|
MD5 | 99ce1ce44af03fafc8293c9f4906aab3 |
|
BLAKE2b-256 | 1afcc6b3f5ad0520aed15b2dc0632a0c6a74d7434e7950f766089e13a8b6631f |