Reputation: 445
I want to make a module and to find the path of the scripts which import my module. For example I have a module: myscript.py which is imported by test.py. I want to print from myscript.py, the path to test.py file
How can i do this? I have read about __ file __, but it doesn't really work the way i imagined it will work.
myscript.py
def printName():
print __file__
test.py - i call this script
import myscript
myscript.printName()
I want to print test.py but it prints myscript.py
Upvotes: 0
Views: 85