best way to compare contents of 2 lists?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Apr 24 13:52:00 EDT 2009
On Fri, 24 Apr 2009 10:39:39 -0700, norseman wrote:
> Technically, == is reserved for identical, as in byte for byte same
Really? Then how do you explain these?
>>> u'abc' == 'abc'
True
>>> 1 == 1.0
True
>>> 2L == 2
True
>>>
>>> import decimal
>>> decimal.Decimal('42') == 42
True
Here's one to think about:
>>> d1 = {-1: None, -2: None}
>>> d2 = {-2: None, -1: None}
>>> print d1, d2
{-2: None, -1: None} {-1: None, -2: None}
>>> d1 == d2
True
If d1 and d2 are equal and both are dictionaries with the same keys and
same values, why do they print in different orders?
--
Steven
More information about the Python-list
mailing list