Phlip wrote:
Consider these two python modules:
aa.py
def a():
print '?'
bb.py
import aa
def bb():
aa.a()
bb()
How do I make the print line emit the filename of bb.py? (It could be
anything.)
Possibly not very reliable in every situation (doctests, other pythons,
...) but this is what I do:
--------- aa.py --------------
import __main__ as CALLER
def mynameis():
print CALLER.__file__
--------- bb.py --------------
import aa
def whosthere():
aa.mynameis()
whosthere()
-------------------------------
OUTPUT: bb.py
hth
G.F.
--
http://mail.python.org/mailman/listinfo/python-list