Suppose we have a Python function:
def func(): # if called in the body of another function, do something # if called as argument to a function, do something different pass
func () can be called in the body of another function:
def funcA(): func()
func () can also be called as an argument to a function:
def funcB(arg1): pass def funcC(**kwargs): pass funcB(func()) funcC(kwarg1=func())
Is there a way to distinguish between these two cases in the body of func ()?
. . Python . Python. . . - , , . , CGA. StackExchange , .
EDIT2. . , , func , -
call_function_on_the_right()>>func()
, . , , . funct() onplevel funca(), , func() , , , . , , , , .
funct()
funca()
func()
? .
? , , , , inspect.stack() .
inspect.stack()
, , , , . .
func(func())
, . f_code, - f_lasti, . , , . - ( dis) , , , .
f_code
f_lasti
dis
100%, , , . , , " ", - . , , "" , .
, , .:)