An oddity in list comparison and element assignment

Slawomir Nowaczyk slawomir.nowaczyk.847 at
Fri Jun 2 00:40:47 CEST 2006

On Thu, 01 Jun 2006 15:12:23 -0700
michael.f.ellis at wrote:

#> I believe that 'is' tests equality of reference, such that
#> >>> a = range(1,3)
#> >>> b = range(1,3)
#> >>> a is b
#> False
#> The 'is' operator tells you whether a and b refer to the same object.
#> What I've been discussing is whether == should test for "structural"
#> equality so that a and b remain equivalent under parallel mutations
#> (and also under single mutations to common references)

What does "parallel mutations" mean? In particular, what should be the
results of each of the following three comparisons:

x, y, z = [1],[1],[1]
a, b = [x,y], [y,z]
c, d = [[1],[1]], [[1],[1]]
a == b
c == d
a == b

So, do I understand correctly that you would like first comparison
(a==b) to return "False" and second comparison (c==d) to return

 Best wishes,
   Slawomir Nowaczyk
     ( Slawomir.Nowaczyk at )

Living on Earth may be expensive, but it includes
an annual free trip around the Sun.

More information about the Python-list mailing list