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

Alex Martelli aleaxit at gmail.com
Tue Feb 14 00:53:31 CET 2006


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


More information about the Python-Dev mailing list