[docs] [issue16851] ismethod and isfunction methods error

Ezio Melotti report at bugs.python.org
Thu Jan 3 17:56:23 CET 2013


Ezio Melotti added the comment:

I think that's expected and by design.  In Python 3 there are no unbound methods, but simply functions:
>>> class X:
...   def add(a, b): return a+b
... 
>>> add = X.add
>>> add
<function add at 0xb740d26c>
>>> add(3, 4)
7
>>> def add(a, b): return a+b
... 
>>> add
<function add at 0xb740d22c>
>>> add(3, 4)
7

As you can see there's no real difference between the two "add".

It's different though with bound methods (obtained from an instance rather than a class):

>>> add = X().add
>>> add
<bound method X.add of <__main__.X object at 0xb740e0ec>>

The documentation is also clear that ismethod() "Return true if the object is a bound method written in Python.".  Maybe an additional note can be added to state that "unbound methods" are not included, and that are instead recognized by isfunction().

----------
assignee:  -> docs at python
components: +Documentation -Library (Lib)
keywords: +easy
nosy: +docs at python, ezio.melotti
stage:  -> needs patch
type: behavior -> enhancement
versions: +Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16851>
_______________________________________


More information about the docs mailing list