Is there a way to get the current function I'm in?
I'm looking for the actual function object, not the function name.
def foo(x,y):
foo_again = <GET_CURRENT_FUNCTION>
if foo_again == foo:
print ("YES they are equal!")
I assume I could do that in Python inspect module, but I can't seem to find it.
EDIT The reason I want that is I want to print out the arguments to my function. And I can do that with inspect. Like this
def func(x,y):
for a in inspect.getfullargspec(func).args:
print (a, locals()[a])
This works, but I don't want to have to manually write the function name. Instead, I want to do
def func(x,y):
for a in inspect.getfullargspec(<GET_CURRENT_FUNCTION>).args:
print (a, locals()[a])