testing two lists for equality

Peter Hansen peter at engcorp.com
Thu Jun 19 16:01:33 EDT 2003


beliavsky at aol.com wrote:
> 
> If x and y are both lists (or tuples), is the expression
> 
> (x == y)
> 
> true if and only if len(x) = len(y) and all of the corresponding
> elements in x and y are the same?
> 
> I did not see this behavior documented in "Python Essential
> Reference", but it makes sense and agrees with a few experiments I
> did.

http://python.org/doc/current/ref/comparisons.html might help.

It basically implies what you said above, if you take "lexicographically"
to mean something like "item by item".




More information about the Python-list mailing list