If there is method t1
in file a.py
and there is a file b.py
, which calls method t1
from a.py
file. How do I get full/absolute path to b.py
file inside t1
method?
With inspect module (just like here: how to get the caller's filename, method name in python), I can get relative path to file, but it seems it does not contain absolute path (or there is some other attribute object, to access to get it?).
As an example:
a.py:
def t1():
print('callers absolute path')
b.py:
from a import t1
t1() # should print absolute path for `b.py`