Message178966
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(). |
|
Date |
User |
Action |
Args |
2013-01-03 16:56:23 | ezio.melotti | set | recipients:
+ ezio.melotti, docs@python, wdanilo |
2013-01-03 16:56:23 | ezio.melotti | set | messageid: <1357232183.0.0.614786408485.issue16851@psf.upfronthosting.co.za> |
2013-01-03 16:56:22 | ezio.melotti | link | issue16851 messages |
2013-01-03 16:56:22 | ezio.melotti | create | |
|