For example:
in the file main/main.py
import core.fun as f
f.script()
and in the file main/core/fun.py:
def script():
f = open('test.txt','r')
where a file test.txt is present in the folder main/core/.
If I run main/main.py it will not work because python will search for the file 'test.txt' in the main folder and not in the main/core folder.
And if I call within the function script()
import os
os.getcwd()
It will again return the directory main
Therefore I would like to know how can I find the directory of the function within the function.