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

Thomas Wouters thomas at xs4all.net
Fri Feb 10 01:03:48 CET 2006

On Thu, Feb 09, 2006 at 03:39:46PM -0800, Aahz wrote:

> Can you provide a couple of examples where you think you'd want __index__
> functionality but the name would be inappropriate?

Not really, or I wouldn't have had only a _slight_ reservation :) There are
many functioncalls and methodcalls that only take integers, though, and they
all currently use int() on their argument. file.read, socket.recv,
signal.signal, str.zfill/center/ljust -- basically anything that uses the
'i' PyArg_Parse* format specifier, which is quite a lot. For a great many of
them it will not make sense to pass objects that don't have an appropriate
__int__, but who knows howmany really *mean* to ask for __index__ instead. I
mostly voice the reservation to lure out people with actual reservations ;)

Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!

More information about the Python-Dev mailing list