Greg Couch added the comment:

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.

----------
nosy: +gregcouch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16851>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to