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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4