Suppose myapp/foo.py
contains:
def info(msg):
caller_name = ????
print '[%s] %s' % (caller_name, msg)
And myapp/bar.py
contains:
import foo
foo.info('Hello') # => [myapp.foo] Hello
I want caller_name
to be set to the __name__
attribute of the calling functions' module (which is 'myapp.foo') in this case. How can this be done?