An oddity in list comparison and element assignment

Jim Segrave jes at nl.demon.net
Thu Jun 1 16:14:09 EDT 2006


In article <1149186735.650036.62670 at i39g2000cwa.googlegroups.com>,
 <michael.f.ellis at gmail.com> wrote:
>Yes. You stated it quite precisely.  I believe l1==l2 should always
>return True and l1==l3 should always be False. (unless l3 is reassigned
>as l3=l1).  Your idea of a separate operator for 'all elements have
>numerically equal values at the moment of comparision' is a good one.
>For want of a better name, it could be called DeepCopyEquality(a,b) and
>would be equivalent to a byte-by-byte comparison of two distinct
>regions in memory created by a deep copies of a and b.

The operator which works at the moment of comaprision is already there
- that's what == does. 
If you really think there's a need for a comparision which includes
dealing with aliasing, then it seems to me a python module with a
set of functions for comparisions would make more sense. 



-- 
Jim Segrave           (jes at jes-2.demon.nl)




More information about the Python-list mailing list