On Sun, Dec 3, 2017 at 6:06 PM, Chris Barker <chris.bar...@noaa.gov> wrote:

> In fact, it's striking me that there may well be classes that are defining
> the comparison magic methods not because they want the objects to "work"
> with the comparison operators, but because that want them to work with sort
> and min, and max, and...
>

An existence proof: in NLTK, an __lt__ method added purely to facilitate
consistent sorting (in doctests) of structured data objects for which
comparison operators do not really make conceptual sense:
https://github.com/nltk/nltk/pull/1902/files#diff-454368f06fd635b1e06c9bb6d65bd19bR689

Granted, calling min() and max() on collections of these objects would not
make conceptual sense either. Still, __sort_key__ would have been cleaner
than __lt__.

Cheers,
Nathan
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to