[Python-Dev] Semantics of __int__(), __index__()

Mark Dickinson dickinsm at gmail.com
Tue Apr 2 11:19:06 CEST 2013


On Tue, Apr 2, 2013 at 10:02 AM, Mark Dickinson <dickinsm at gmail.com> wrote:

> On Tue, Apr 2, 2013 at 9:58 AM, Maciej Fijalkowski <fijall at gmail.com>wrote:
>
>>
>> My 2 cents here is that which one is called seems to be truly random.
>> Try looking into what builtin functions call (for example list.pop
>> calls __int__, who knew)
>>
>
> That sounds like a clear bug to me.  It should definitely be using
> __index__.
>

Ah, and I see it *is* using `__index__` in Python 3; just not in Python
2.7.  It may be one of those Python 2 bugs that's not worth fixing because
the fix would do more harm (in the form of breakage of existing code) than
good.

-- 
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130402/942b332a/attachment.html>


More information about the Python-Dev mailing list