Returns True if the given object is an instance method of the class it is defined on (as opposed to a staticmethod or a classmethod).
This requires both the class the object is a member of as well as the object itself in order to make this determination.
Parameters: | cls : type
obj : object
|
---|
Examples
>>> from astropy.extern import six
>>> class MetaClass(type):
... def a_classmethod(cls): pass
...
>>> @six.add_metaclass(MetaClass)
... class MyClass(object):
... __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