An oddity in list comparison and element assignment
Maric Michaud
maric at aristote.info
Fri Jun 2 04:27:11 EDT 2006
Le Vendredi 02 Juin 2006 00:12, michael.f.ellis at gmail.com a écrit :
> 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.
Yeah ! That's it. And you proposed a definition of identity :
for all operator op, op(a) = op(b) => a = b
This is of poor use in real life where two thing are never identical, just
comparable.
> 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)
So you wanted a comparison opertor of twto sequence dafined like this :
seq1 == seq2 => for all e in seq1, seq2[seq1.index(e) *is* e
!!! this would not be very useful nor consistent I guess and prefer the one
used in python :
seq1 == seq2 => for all e in seq1, seq2[seq1.index(e) == e
--
_____________
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