Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14126

Getting the file name of an ipython notebook

$
0
0

For python files I can get the file name and use to as a prefix for the generated results using:

prefix = os.path.splitext(os.path.basename(main.__file__))[0]

But this fails for ipython notebooks with the following error:

---> 23     return os.path.splitext(os.path.basename(main.__file__))[0]AttributeError: module '__main__' has no attribute '__file__'

Is there a reasonable way to get the current notebook's name?

Previously suggested solutions, like ipyparams and ipynbname don't seem to work for me.


Viewing all articles
Browse latest Browse all 14126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>