◐ Shell
clean mode source ↗

Message 370190 - Python tracker

> 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__.