This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 ethan.furman
收信人 Arfrever, benjamin.peterson, ethan.furman, r.david.murray
日期 2013-12-29.08:11:37
SpamBayes Score -1.0
Marked as misclassified
Message-id <1388304698.46.0.263644104501.issue20092@psf.upfronthosting.co.za>
In-reply-to
内容
In issue19995, in msg206339, Guido exhorted:
--------------------------------------------
>> [Ethan claimed] it is possible to want a type that can be used as an
>> index or slice but that is still not a number
>
> I'm sorry, but this requirement is absurd. An index *is* a number. You
> have to make up your mind. (I know, in the context of the example that
> started this, this is funny, but I still stand by it.)
>
> Finally, the correct name should perhaps have been __integer__ but I don't
> see enough reason to change it now.

The de facto API that is forming is that if an actual int is needed from an actual integer type (not float, not complex, not etc.), then __index__ is used.  If __index__ is not defined by some numeric type then it will not be considered a true int in certain key places in Python, such as as indices, arguments to hex(), etc.

Making the change suggested in the title would help solidify the API.
历史
日期 用户 动作 参数
2013-12-29 08:11:38ethan.furman修改recipients: + ethan.furman, benjamin.peterson, Arfrever, r.david.murray
2013-12-29 08:11:38ethan.furman修改messageid: <1388304698.46.0.263644104501.issue20092@psf.upfronthosting.co.za>
2013-12-29 08:11:38ethan.furman链接issue20092 messages
2013-12-29 08:11:37ethan.furman创建