[Python-Dev] [Python-checkins] r87445 - python/branches/py3k/Lib/numbers.py

Nick Coghlan ncoghlan at gmail.com
Fri Dec 24 02:08:08 CET 2010


On Fri, Dec 24, 2010 at 4:41 AM, eric.araujo <python-checkins at python.org> wrote:
> Author: eric.araujo
> Date: Thu Dec 23 19:41:33 2010
> New Revision: 87445
>
> Log:
> Fix small inaccuracy: there is no index function

Yes, there is, it just isn't a builtin - it lives in the operator module.

>     def __index__(self):
> -        """index(self)"""
> +        """someobject[self]"""
>         return int(self)

Changing the docstring to say "operator.index(self)" would be the
clearest solution here. (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).

Cheers,
Nick.

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


More information about the Python-Dev mailing list