Say I have two files in different directories: 1.py
(say, in C:/FIRST_FOLDER/1.py
) and 2.py
(say, in C:/SECOND_FOLDER/2.py
).
The file 1.py
imports 2.py
(using sys.path.insert(0, #path_of_2.py)
followed, obviously, by import 2
) and calls one of the functions in 2.py
, the function it calls needs to know the absolute path of 1.py
(it looks for a file in that same directory).
I know there's inspect.stack()[1]
but this only returns the file name and not the path.
Any idea on how to implement this?