test for list equality

MRAB python at mrabarnett.plus.com
Thu Dec 15 13:12:33 EST 2011


On 15/12/2011 17:59, Miki Tebeka wrote:
>>  My sort issue... as in this doesn't work
>>  >>>  if x.sort == y.sort:
> You're missing the () to make it a function call.
> Also list.sort() returns none, it mutates the original list.
> You can either
>      sorted(x) == sorted(y)
> or
>      set(x) == set(y)

But don't use sets if there may be duplicates.



More information about the Python-list mailing list