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.

Uri Cohen
  • 3,488
  • 1
  • 29
  • 46

1 Answers1

0

Someone already posted a workaround using JavaScript. You can find the original question here: https://stackoverflow.com/a/44589075