[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
Fri Feb 10 00:39:46 CET 2006


On Fri, Feb 10, 2006, Thomas Wouters wrote:
> 
> I have a slight reservation about the name. On the one hand it's clear the
> canonical use will be for indexing sequences, and __index__ doesn't look
> enough like __int__ to get people confused on the difference. On the other
> hand, there are other places (in C) that want an actual int, and they could
> use __index__ too. Even more so if a PyArg_Parse* grew a format for 'the
> index-value for this object' ;)
> 
> On the *other* one hand, I can't think of a good name... but on the other
> other hand, it would be awkward to have to support an old name just because
> the real use wasn't envisioned yet.

Can you provide a couple of examples where you think you'd want __index__
functionality but the name would be inappropriate?
-- 
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