Assume that there is a file named a.py with the following content:
import sys
sys.path.append("path")
import b
Now, there is a directory named path in the same directory as a.py. My goal is to get the path of a.py. How can it be achieved?
import os
print (os.path.realpath(__file__))
When I execute a.py from an arbitrary directory, I get the path of b.py, instead of the one of a.py. Of course, this behaviour is normal, but how can it be changed?