[Python-Dev] Are PyCFunctions supposed to invisibly consume self when used as a method?
Guido van Rossum
guido at python.org
Sun Jun 13 01:16:17 CEST 2010
(Of course, I'd still like to see the warning, since it's now a
portability issue.)
On Sat, Jun 12, 2010 at 4:15 PM, Guido van Rossum <guido at python.org> wrote:
> Hey! No borrowing the time machine! :-)
>
> On Sat, Jun 12, 2010 at 4:03 PM, Christian Heimes <lists at cheimes.de> wrote:
>>> 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);
>> + SETBUILTIN("instancemethod", &PyInstanceMethod_Type);
>> SETBUILTIN("list", &PyList_Type);
>> SETBUILTIN("map", &PyMap_Type);
>> SETBUILTIN("object", &PyBaseObject_Type);
>>
>>
>>>>> class Example:
>> ... iid = instancemethod(id)
>> ... id = id
>> ...
>>>>> Example().id()
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> TypeError: id() takes exactly one argument (0 given)
>>>>> Example().iid()
>> 139941157882144
>>
>> Christian
>>
>> _______________________________________________
>> Python-Dev mailing list
>> Python-Dev at python.org
>> http://mail.python.org/mailman/listinfo/python-dev
>> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
>>
>
>
>
> --
> --Guido van Rossum (python.org/~guido)
>
--
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev
mailing list