[issue18712] Pure Python operator.index doesn't match the C version.
Armin Rigo
report at bugs.python.org
Sat Aug 17 18:12:23 CEST 2013
Armin Rigo added the comment:
Sorry, realized that my pure Python algorithm isn't equivalent to _PyType_Lookup() --- it fails the staticmethod example of Serhiy. A closer one would be:
for t in type(a).__mro__:
if '__index__' in t.__dict__:
return t.__dict__['__index__'].__get__(a)()
But it's still not a perfect match. I think right now the only "perfect" answer is given by workarounds like "range(a).stop"...
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18712>
_______________________________________
More information about the Python-bugs-list
mailing list