On 03/11/2020 11:16 AM, Andrew Barnert via Python-ideas wrote:
On Mar 11, 2020, at 02:42, Steve Jorgensen wrote:

Take the following example:

```
    def __lt__(self, other):
        return not self.__ge__(other):

    def __le__(self, other):
        return not self.__gt__(other):

    def __ge__(self, other):
        <some code that might or might not return NotImplemented>
```

Usually you can just use @total_ordering.

Even @total_ordering suffered from this bug for a number of years.

 [...] you [may] just want `return not self >= other` [in the `__dunder__`]

It's been my experience that when working with `__dunders__`, I'm better off
sticking with `__dunders__`, at least with the rich comparison operators.

[...] you really do need to deal with their API, including testing for
 NotImplemented with it.

Forgetting to deal with `NotImplemented` is a common mistake.  Is there any
context in which `bool(NotImplemented)` actually makes sense?

So this doesn’t seem like much of a problem, much less a problem worth
 breaking fundamental truthiness for a builtin type.

Considering that the stdlib itself has suffered from it, I would say it's more
than a small problem.

--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/IHIGZR7CQBQ47KKSX3MJ7STUVSNKYHAS/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to