If I want the path of the current module, I’ll use __file__.
Now let’s say I want a function to return that. I can’t do:
def get_path():
return __file__
Because it will return the path of the module the function has been declared in.
I need it to work even if the function is not called at the root of the module but at any level of nesting.
This is how I would do it: