Thursday 8 September 2022

Get __name__ of calling function's module in Python

 import inspect 


def info(msg):
    frm = inspect.stack()[1]
    mod = inspect.getmodule(frm[0])
    print '[%s] %s' % (mod.__name__, msg)


from: https://stackoverflow.com/questions/1095543/get-name-of-calling-functions-module-in-python

No comments:

Post a Comment