Suppose I have two modules:
a.py:
import b
print __name__, __file__
b.py:
print __name__, __file__
I run the "a.py" file. This prints:
b C:pathocode.py
__main__ C:pathocodea.py
Question: how do I obtain the path to the __main__
module ("a.py" in this case) from within the "b.py" library?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…