# 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](https://forums.fast.ai/t/jupyter-notebook-enhancements-tips-and-tricks/17064/39).
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:
```python
import ipynbname
nb_fname = ipynbname.name()
```
Get the full path to the notebook:
```python
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](https://github.com/msm1089/ipynbname/issues/17#issuecomment-1293269863).
Raw data
{
"_id": null,
"home_page": "https://github.com/msm1089/ipynbname",
"name": "ipynbname",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.4",
"maintainer_email": "",
"keywords": "jupyter,notebook,filename",
"author": "Mark McPherson",
"author_email": "msm1089@yahoo.co.uk",
"download_url": "https://files.pythonhosted.org/packages/7c/46/73e920d3c1ce8dd155fd934c10773c1add749bb9726c5339658eadd13808/ipynbname-2023.2.0.0.tar.gz",
"platform": null,
"description": "# ipynbname\r\n\r\nWhen run in a Jupyter notebook, simply returns the notebook filename or the full path to the notebook.\r\nI created this to help with automating posting blog posts written in Jupyter notebooks directly to\r\nGitHub Pages.\r\n\r\nYou would think there was already some built-in way to access the current notebook name, but it took many hours\r\nof searching for a way to do it. As it seems many others did, I tried using Javascript, but the async nature of\r\nJS meant that it was unreliable. Finally I stumbled on this [post](https://forums.fast.ai/t/jupyter-notebook-enhancements-tips-and-tricks/17064/39).\r\nI have refactored the code there so a user can get either the name or path, but credit for most of the code\r\ngoes to the author of this post, thanks!\r\n\r\n## Examples\r\n\r\nGet the notebook name:\r\n\r\n```python\r\nimport ipynbname\r\nnb_fname = ipynbname.name()\r\n```\r\n\r\nGet the full path to the notebook:\r\n\r\n```python\r\nimport ipynbname\r\nnb_path = ipynbname.path()\r\n```\r\n## Limitations\r\n\r\nNote that this only reliably works when running a notebook in a browser. So it does not currently work for things like nbconvert or papermill.\r\n\r\nFor VS Code there is a [workaround](https://github.com/msm1089/ipynbname/issues/17#issuecomment-1293269863).\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simply returns either notebook filename or the full path to the notebook when run from Jupyter notebook in browser.",
"version": "2023.2.0.0",
"project_urls": {
"Homepage": "https://github.com/msm1089/ipynbname"
},
"split_keywords": [
"jupyter",
"notebook",
"filename"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1290a8bfb680d1d531c0930d15307f4a2b7529409f27e99deac08a7d891ae2ae",
"md5": "24356e9d81c1ff9c16365ac218c26f10",
"sha256": "a88f4b1f840c4a12fe6e39862f936c1ccec70705fb034a8639f8e7752bf82637"
},
"downloads": -1,
"filename": "ipynbname-2023.2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "24356e9d81c1ff9c16365ac218c26f10",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.4",
"size": 4345,
"upload_time": "2023-07-25T06:45:51",
"upload_time_iso_8601": "2023-07-25T06:45:51.712327Z",
"url": "https://files.pythonhosted.org/packages/12/90/a8bfb680d1d531c0930d15307f4a2b7529409f27e99deac08a7d891ae2ae/ipynbname-2023.2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7c4673e920d3c1ce8dd155fd934c10773c1add749bb9726c5339658eadd13808",
"md5": "66e9929e3958433204dea09212b5aef2",
"sha256": "462bbdd7956624876dc4ea81fa792845ab3870e444ca1f6b7acdaea37d8c9ebf"
},
"downloads": -1,
"filename": "ipynbname-2023.2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "66e9929e3958433204dea09212b5aef2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.4",
"size": 4179,
"upload_time": "2023-07-25T06:45:53",
"upload_time_iso_8601": "2023-07-25T06:45:53.263216Z",
"url": "https://files.pythonhosted.org/packages/7c/46/73e920d3c1ce8dd155fd934c10773c1add749bb9726c5339658eadd13808/ipynbname-2023.2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-25 06:45:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "msm1089",
"github_project": "ipynbname",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ipynbname"
}