🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

ipynbname

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipynbname

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

2024.1.0.0
PyPI
Maintainers
1

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.

Keywords

jupyter

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts