I know that __file__ contains the filename containing the code, but is there a way to get the name of the script/file that's calling the function?
If I have a file named filenametest_b.py:
def printFilename():
print(__file__)
And I import the function in filenametest_a.py:
from filenametest_b import *
printFilename()
I get:
C:\Users\a150495>python filenametest_a.py
C:\Users\a150495\filenametest_b.py
Is there something I can do in the b file to print the name of the a file?
sys.argv[0]