Semantics of ==

Erik Max Francis max at alcyone.com
Fri Mar 26 18:44:50 EST 2004


Axel Boldt wrote:

> Erik Max Francis <max at alcyone.com> wrote
> 
> > What part of the semantics are you unclear about?  Two sequences are
> > equal if they are element-wise equal.
> 
> That definition is circular.

No, because presumably you already understand what equality means for
two non-sequence objects.

> > and that definition is even consistent with the behavior you saw
> > with the
> > self-referencing lists which for some reason surprised you.
> 
> Yes, s==w is consistent with the definition, but s!=w would also have
> been consistent with it.

As I already demonstrated in your initial response, Python's behavior in
your examples was completely consistent with this definition, whether
you realize it or not.  The cases that you thought shouldn't have been
equal were in fact equal, and the cases that you thought should have
been equal weren't, in fact, equal.  I and several others carefully
demonstrated this to you, but you ignored us so that you could continue
ranting that Python's list equality is broken, when there is no evidence
that it is.

> Consider for instance the following definition:
> * all strings and numbers are called "well-founded"
> * a list is called well-founded if and only if all its elements are
> well-founded.
> 
> l=[]
> l.append(l)
> Is l well-founded? Both answers "yes" and "no" are consistent with the
> above definition.

No they aren't, since l's first element is a list, not a string or
number.

What is the point of this definition?

-- 
 __ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
\__/ Drifting from woman-who-tries misconstrued / Shifting to
    woman-wise -- Lamya



More information about the Python-list mailing list