[Python-Dev] [Python-checkins] r87445 - python/branches/py3k/Lib/numbers.py (original) (raw)
Éric Araujo merwok at netwok.org
Sun Dec 26 18:13:53 CET 2010
- Previous message: [Python-Dev] [Python-checkins] r87445 - python/branches/py3k/Lib/numbers.py
- Next message: [Python-Dev] [Python-checkins] r87445 - python/branches/py3k/Lib/numbers.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Le 24/12/2010 02:08, Nick Coghlan a écrit :
On Fri, Dec 24, 2010 at 4:41 AM, eric.araujo <python-checkins at python.org> wrote:
Fix small inaccuracy: there is no index function Yes, there is, it just isn't a builtin - it lives in the operator module. Defining object.index with operator.index seems pretty circular to me :) http://docs.python.org/dev/reference/datamodel#object._index_ does it, but it should be fixed IMO. The difference between int and index is also not clear.
def index(self): - """index(self)""" + """someobject[self]""" return int(self) Changing the docstring to say "operator.index(self)" would be the clearest solution here. I disagree. add is documented as implementing +, not operator.add.
(Choosing to accept arbitrary index objects as integer equivalents is up to the object being indexed, just like interpreting slices is - a dict, for example, will never invoke index methods). I honestly don’t know what the best fix is. We could copy the doc from datamodel (“called whenever Python needs an integer object (such as in slicing, or in the built-in bin(), hex() and oct() functions)”). I’ve been told on IRC to let Mark Dickison decide how to fix the docstrings in the numbers module (deleting them being of course an option: magic methods are documented in the language reference, they don’t need docstrings).
Regards
- Previous message: [Python-Dev] [Python-checkins] r87445 - python/branches/py3k/Lib/numbers.py
- Next message: [Python-Dev] [Python-checkins] r87445 - python/branches/py3k/Lib/numbers.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]