import sys
class A:
def __init__(self, name):
f_name = sys._getframe().f_code.co_name
var = sys._getframe().f_code.co_varnames
caller_name = sys._getframe().f_back.f_code.co_name
print("{}, {} : {}".format(f_name, var, caller_name))
def __call__(selt, name):
f_name = sys._getframe().f_code.co_name
caller_name = sys._getframe().f_back.f_code.co_name
print("{} : {}".format(f_name,caller_name))
return name
def Foo():
a = A("GG")
b = a("FF")
Foo()
# 결과
# __init__, ('self', 'name', 'f_name', 'var', 'caller_name') : Foo
# __call__ : Foo