On Sun, Oct 31, 2021 at 01:32:29PM +1300, Greg Ewing wrote:
> On 31/10/21 5:47 am, Raymond Bisdorff wrote:
> >Should the tuples comparison is in this case, I thought, not be solely 
> >based on the first tuple component?
> 
> Whether you think it should or shouldn't, the fact is that it's not.
> This is documented in Section 5.6 of the Library Reference:
> 
> "tuples and lists are compared lexicographically by comparing 
> corresponding elements. This means that to compare equal, every element 
> must compare equal and the two sequences must be of the same type and 
> have the same length."

I don't think that applies if you provide a key function. In context, 
Raymond is referring to using itemgetter(0) as the key function, so only 
the first item in the tuple will be considered.

-- 
Steve
_______________________________________________
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/NOTXDVEMIAE5YKREK274QEPJGX6OA7JO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to