I want to store currently running Jupyter notebook name in python variable. I create 2 cells
from IPython.display import display,Javascript
Javascript('IPython.notebook.kernel.execute("notebook_name = " + "\'"+IPython.notebook.notebook_name+"\'");')
and
notebook_name
This works fine if I execute cells one after another, but I mostly execute cells with "run all cells" command, and in this case I get the error:
NameError: name 'notebook_name' is not defined
I get the same error if I unite previous 2 cells into 1 cell. I believe this is due to synchronization between python and JavaScript. Any help is appreciated.