Armin Rigo added the comment:

Just mentioning it here again, but "type(a).__index__(a)" is still not 
perfectly correct.  Attached is a case where it differs.

I think you get always the correct answer by evaluating "range(a).stop".  It's 
admittedly obscure...  For example:

    class A:
        def __index__(self):
            return -42**100

    a = A()
    print(range(a).stop)

----------
nosy: +arigo
Added file: http://bugs.python.org/file31334/x.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18712>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to