[Python-Dev] Range contains and objects with index methods (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Mon Dec 27 07:13:16 CET 2010


On Mon, Dec 27, 2010 at 11:52 AM, Terry Reedy <tjreedy at udel.edu> wrote:

Return a converted to an integer. Equivalent to a.index()." comes close to implying equality (if possible).

What are the actual used of .index?

PEP 357 gives the original rationale - it was to allow integer-like objects (such as numpy scalars) to be used as sequence indices, as well as slice parameters.

I would have to grep the source to get a full list of uses, but I believe it is already used in at least those two cases, as well as for sequence repetition (via '*') and to identify permitted inputs to bin/oct/hex.

Cheers, Nick.

-- Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-Dev mailing list