[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation

Guido van Rossum guido at python.org
Tue Feb 14 01:07:56 CET 2006

Sorry, you're right. operator.index() sounds fine.


On 2/13/06, Alex Martelli <aleaxit at gmail.com> wrote:
> On 2/13/06, Guido van Rossum <guido at python.org> wrote:
>    ...
> > I don't like to add a built-in index() at this point; mostly because
> > of Occam's razor (we haven't found a need).
> I thought you had agreed, back when I had said that __index__ should
> also be made easily available to implementors of Python-coded classes
> implementing sequences, more elegantly than by demanding that they
> code x.__index__() [I can't think offhand of any other special-named
> method that you HAVE to call directly -- there's always some syntax or
> functionality in the standard library to call it more elegantly on
> your behalf].  This doesn't neessarily argue that index should be in
> the built-ins module, of course, but I thought there was a sentiment
> towards having it in either the operator or math modules.
> Alex

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list