This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gregcouch
Recipients chris.jerdonek, docs@python, eric.araujo, ezio.melotti, federico.reghenzani, gregcouch, wdanilo
Date 2013-02-12.00:07:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1360627629.48.0.628654026974.issue16851@psf.upfronthosting.co.za>
In-reply-to
Content
In my opinion, the Python 2.7 results are wrong.

In Python 2.7, inspect.ismethod returns True for both bound and unbound methods -- ie., is broken according to the documentation.  As a workaround, I'm using:

def is_bound_method(obj):
    return hasattr(obj, '__self__') and obj.__self__ is not None

is_bound_method also works for methods of classes implemented in C, e.g., int:

>>> a = 1
>>> is_bound_method(a.__add__)
True
>>> is_bound_method(int.__add__)
False

But is not very useful in that case because inspect.getargspec does not work for functions implemented in C.

is_bound_method works unchanged in Python 3, but as noted above, in Python 3, inspect.ismethod properly distinguishes between bound and unbound methods, so it is not necessary.
History
Date User Action Args
2013-02-12 00:07:09gregcouchsetrecipients: + gregcouch, ezio.melotti, eric.araujo, chris.jerdonek, docs@python, federico.reghenzani, wdanilo
2013-02-12 00:07:09gregcouchsetmessageid: <1360627629.48.0.628654026974.issue16851@psf.upfronthosting.co.za>
2013-02-12 00:07:09gregcouchlinkissue16851 messages
2013-02-12 00:07:09gregcouchcreate