What is the correct way in Python 3.7+ to check if a function is defined within a Python class. Example:
class A:
def fun1(self):
pass
def fun2():
pass
I would like to distinguish that A.fun1 was defined within a class and fun2 is not.
magic(A.fun1)should returnTrueandmagic(fun2)should returnFalse, right?ismethodshould be called on object. Do these:print(inspect.ismethod(A().fun1), inspect.isfunction(A().fun1)); print(inspect.ismethod(fun2), inspect.isfunction(fun2)).