[issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

Mark Dickinson report at bugs.python.org
Thu May 28 07:07:35 EDT 2020


Mark Dickinson <dickinsm at gmail.com> added the comment:

> The other way to solve my problem would be to provide an operator module function (operator.as_float?) that does a duck-typed conversion of an arbitrary Python object to a float.

This does feel like the *right* solution to me. See #40801 and the linked PR. If we can do something like this, I'd be happy to drop the expectation that __float__ return something of exact type float, and similarly for __index__.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue17576>
_______________________________________


More information about the Python-bugs-list mailing list