-1

I have a Jupyter notebook(parent.ipynb) which runs another notebook(child.ipynb) inside it.

Is there a way to get the filename of the parent file from inside the child file? My child file has a logger and therefore can be called by multiple files. It needs to know which file is calling the logger to create log records and therefore I was wondering if there is any magic or any sort of method that can help me with this.

Basically,

A.ipynb

[1] %run B.ipynb

B.ipynb

-- insert code that can print parent filename when called --

halfer
  • 19,471
  • 17
  • 87
  • 173
Aakash Verma
  • 3,170
  • 2
  • 23
  • 55

1 Answers1

-1

add header inside the parent file as follow:

import child
Dejene T.
  • 443
  • 4
  • 11