[Python-Dev] [Python-checkins] r87445 - python/branches/py3k/Lib/numbers.py (original) (raw)

Terry Reedy tjreedy at udel.edu
Mon Dec 27 02:58:34 CET 2010


On 12/26/2010 7:01 PM, Nick Coghlan wrote:

Yes, the definition in the language reference could definitely be improved to mention the semantics first, and then reference operator.index second.

Possible wording "Indicates to the Python interpreter that the object is semantically equivalent to the returned integer, rather than merely supporting a possibly lossy coercion to an integer

If that is the intent of index, the doc should say so more clearly. That clarification would change my answer to your question about range.

(i.e. as the int method allows for types like float and decimal.Decimal). This allows non-builtin objects to be used as sequence indices, elements of a slice definition, multiplies in sequence repetition, etc. Can be invoked explicitly from Python code via operator.index()"

Removing the circularity from the definitions of index and operator.index doesn't have a great deal to do with the docstrings in numbers.py, though.

It is both related and needed though. IE, it is hard to answer questions about what to to with .index if the intended meaning of .index is not very clear ;-).

-- Terry Jan Reedy



More information about the Python-Dev mailing list