[Python-Dev] Indexing builtin sequences with objects which supply __int__

Guido van Rossum guido@python.org
Fri, 12 Jul 2002 11:26:41 -0400


I've thought about this more, and I think I don't want to make the
requested change (accept objects which implement __int__ as valid
sequence indices).  I also don't want to add a new protocol
(the proposed __index__).

I suggest that you try to find a solution that works without requiring
changes to Python -- that way you have a much better chance that your
code will work with Python 2.2, which will very likely have a lifetime
comparable to that of Python 1.5.2 (in parallel with 2.3, for sure).

I understand your desire to equate 0-D arrays and scalars, but I'm
afraid that's not how the rest of Python works.  I don't think we
should change Python's semantic framework with APL's.

I'm neutral on what you should do instead; personally, I'd continue to
return Python scalars for 0-D arrays, but you could switch to 0-D
arrays if you think the advantages outweigh the disadvantages.

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