[Python-Dev] Are PyCFunctions supposed to invisibly consume self when used as a method? (original) (raw)

Christian Heimes lists at cheimes.de
Sun Jun 13 01:03:44 CEST 2010


method or instancemethod perhaps?

The necessary code is already in Python 3.0's code base. I've added in in r56469 as requested in my issue http://bugs.python.org/issue1587. It seems we had this very discussion over two and a half year ago.

Index: Python/bltinmodule.c

--- Python/bltinmodule.c (Revision 81963) +++ Python/bltinmodule.c (Arbeitskopie) @@ -2351,6 +2351,7 @@ SETBUILTIN("frozenset", &PyFrozenSet_Type); SETBUILTIN("property", &PyProperty_Type); SETBUILTIN("int", &PyLong_Type);

class Example: ... iid = instancemethod(id) ... id = id ... Example().id() Traceback (most recent call last): File "", line 1, in TypeError: id() takes exactly one argument (0 given) Example().iid() 139941157882144

Christian



More information about the Python-Dev mailing list