An oddity in list comparison and element assignment

michael.f.ellis at gmail.com michael.f.ellis at gmail.com
Thu Jun 1 18:12:23 EDT 2006


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)

Cheers,
Mike

Maric Michaud wrote:
> Le Jeudi 01 Juin 2006 18:00, michael.f.ellis at gmail.com a écrit :
> > Perhaps the most fundamental notion is mathematics is that the left and
> > right sides of an equation remain identical after any operation applied
> > to both sides.
>
> IMHO, you are not aware that the '=' symbol of mathematics exists in python,
> it's the 'is' assertion.
>
> a is b
> and then, do what you want with a (or b), a is b remains True.
>
> THIS is the meaning of expr1 = expr2, but in computer science, this is not as
> important as it is in pure logic (most languages do not even provide the 'is'
> assertion).
>
> --
> _____________
>
> Maric Michaud
> _____________
>
> Aristote - www.aristote.info
> 3 place des tapis
> 69004 Lyon
> Tel: +33 426 880 097




More information about the Python-list mailing list