On Sat, Dec 14, 2019 at 04:20:43PM +0200, Serhiy Storchaka wrote:
> 14.12.19 15:29, Steven D'Aprano пише:
> >I might be misinterpreting the evidence, but sorting works on objects
> >that define `__gt__` without `__lt__`.
[...]
> The `<` operator try to use `__lt__`, but if it is not defined falls 
> back to `__gt__`.

Thanks Serhiy, that makes sense. The docs for special methods say that 
`__gt__` is the reflected version of `__lt__`.

Which brings me back to my original question:

Since list.sort guarantees that it will only use the `<` less than 
operator, should we make the same guarantee for sorted, min and/or max?

It would be odd if the guarantee applies to list.sort but not sorted.



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

Reply via email to