[Python-Dev] Coercion and comparisons
Ka-Ping Yee
ping@lfw.org
Tue, 6 Feb 2001 11:24:25 -0800 (PST)
On Tue, 6 Feb 2001, Ka-Ping Yee wrote:
> Category Python operators E operators
>
> identity is, is not ==, !=
> value ==, !=, <> x.equals(y), !x.equals(y)
> magnitude <, <=, >, >= <, <=, >, >=, <>, <=>
>
> Each type of equality has a specific and useful meaning. Most
> languages, including Python, acknowledge the first two. But you
> can see how the coercion problem raised above is a consequence
> of the fact that the third category is incomplete.
I didn't state that last sentence very well, and the table's a bit
inaccurate.
Rather, it would be better to say that '==' and '!=' end up having
to do double duty (sometimes for value equality, sometimes for
magnitude equality) -- when really '==' doesn't belong with
ordering operators like '<'. It's quite a separate concept.
-- ?!ng
"There's no point in being grown up if you can't be childish sometimes."
-- Dr. Who