cmp of multiple attributes

Steven Bethard steven.bethard at gmail.com
Wed Dec 22 14:30:32 EST 2004


Alex Martelli wrote:
> Comparisons of tuples, lists, etc, are *lexicographical*: the first
> items are compared; iff they're equal, then the second items, and so
> forth.  IOW, exactly what you want in this case.

Just to check my understanding, this means that:

     cmp(a0, b0) or cmp(a1, b1) or ... or cmp(aN, bN)

should give the same result as:

     cmp((a0, a1, ... aN), (b0, b1, ... bN))

right?

Steve



More information about the Python-list mailing list