You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be cool, if the __file__ variable present in traditional Python scripts also existed with a notebook. This could be especially helpful when generating dynamic paths.
Other Python double underscore methods, such as __doc__ and __name__, are already present. Why not add this one?
The text was updated successfully, but these errors were encountered:
FWIW, a traditional interactive Python session doesn't define __file__ either.
I guess the kernel isn't associated with any file. It's just started and waits for Jupyter clients to connect. It doesn't even necessarily have to know that one of the clients happens to be a Jupyter Notebook which happens to have physical file associated with it.
If you want to get the notebook name from within the running Notebook, you can try to get it via JavaScript. In the JavaScript namespace there seem to be several related things (and probably more?):
This request has been kicked around quite a bit in the past. This requires client-side information. Implementing this as a cell magic would pretty clean and sensible.
It would be cool, if the
__file__
variable present in traditional Python scripts also existed with a notebook. This could be especially helpful when generating dynamic paths.Other Python double underscore methods, such as
__doc__
and__name__
, are already present. Why not add this one?The text was updated successfully, but these errors were encountered: