isinstancemethod#
- astropy.utils.introspection.isinstancemethod(cls, obj)[source]#
Returns
True
if the given object is an instance method of the class it is defined on (as opposed to astaticmethod
or aclassmethod
).This requires both the class the object is a member of as well as the object itself in order to make this determination.
- Parameters:
Examples
>>> class MetaClass(type): ... def a_classmethod(cls): pass ... >>> class MyClass(metaclass=MetaClass): ... def an_instancemethod(self): pass ... ... @classmethod ... def another_classmethod(cls): pass ... ... @staticmethod ... def a_staticmethod(): pass ... >>> isinstancemethod(MyClass, MyClass.a_classmethod) False >>> isinstancemethod(MyClass, MyClass.another_classmethod) False >>> isinstancemethod(MyClass, MyClass.a_staticmethod) False >>> isinstancemethod(MyClass, MyClass.an_instancemethod) True