def special_func(x):
    callingframe = sys._getframe(1)
print('My caller is the %r function in a %r class' % (callingframe.f_code.
    co_name, callingframe.f_locals['self'].__class__.__name__))
Get function callers' information in python