Message207075
I have the following as part of the patch for that issue:
---------------------------------------------------------
diff -r b668c409c10a Doc/reference/datamodel.rst
--- a/Doc/reference/datamodel.rst Sat Dec 28 20:37:58 2013 +0100
+++ b/Doc/reference/datamodel.rst Sun Dec 29 06:55:11 2013 -0800
@@ -2073,23 +2073,31 @@ left undefined.
builtin: float
builtin: round
Called to implement the built-in functions :func:`complex`,
:func:`int`, :func:`float` and :func:`round`. Should return a value
of the appropriate type.
.. method:: object.__index__(self)
- Called to implement :func:`operator.index`. Also called whenever Python needs
- an integer object (such as in slicing, or in the built-in :func:`bin`,
- :func:`hex` and :func:`oct` functions). Must return an integer.
+ Called to implement :func:`operator.index`, and whenever Python needs to
+ losslessly convert the numeric object to an integer object (such as in
+ slicing, or in the built-in :func:`bin`, :func:`hex` and :func:`oct`
+ functions). Presence of this method indicates that the numeric object is
+ an integer type. Must return an integer.
+
+ .. note::
+
+ When :meth:`__index__` is defined, :meth:`__int__` should also be defined,
+ and both shuld return the same value, in order to have a coherent integer
+ type class.
---------------------------------------------------------
If for some reason that patch doesn't make it into 3.4 I'll split the doc change off to its own issue, unless you think it should be split off anyway? |
|
Date |
User |
Action |
Args |
2013-12-29 14:57:18 | ethan.furman | set | recipients:
+ ethan.furman, benjamin.peterson, Arfrever, r.david.murray |
2013-12-29 14:57:18 | ethan.furman | set | messageid: <1388329038.19.0.222577494877.issue20092@psf.upfronthosting.co.za> |
2013-12-29 14:57:18 | ethan.furman | link | issue20092 messages |
2013-12-29 14:57:17 | ethan.furman | create | |
|