[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
Aahz
aahz at pythoncraft.com
Mon Feb 13 22:43:45 CET 2006
On Mon, Feb 13, 2006, Jim Jewett wrote:
>
> getattr and getattribute are both things you might reasonably want to
> do. __int__ is something you probably shouldn't be doing very often
> anymore; it is being kept for backwards compatibility.
And how do you convert a float to an int? __int__ is NOT going away; the
sole purpose of __index__ is to enable sequence index functionality and
similar use-cases for int-like objects that do not subclass from int.
(For example, one might want to allow an enumeration type to index into
a list.)
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"19. A language that doesn't affect the way you think about programming,
is not worth knowing." --Alan Perlis
More information about the Python-Dev
mailing list