On Sat, 14 Jan 2006 18:21:28 -0500, Mike Meyer wrote:

> Paul Rubin <http://[EMAIL PROTECTED]> writes:
>> Mike Meyer <[EMAIL PROTECTED]> writes:
>>> > Whether the '==' operation conforms to your idea of what equality
>>> > means is unclear.
>>> Care to say what it does mean, then?
>> I'd say a==b doesn't necessarily mean a and b have the same value.
> 
> Care to say what it does mean (as opposed to what it doesn't mean), then?

Since you can overload __eq__, it means anything the programmer wants it
to mean. And if there is a bug, something he doesn't mean.

But ignoring pathological cases, a==b means that a and b are equal,
whatever equal means in the context. Equal might mean that a and b:

- are the same object;
- are different objects with equal values;
- are different objects with equivalent values;
- have the same value when converted to a common type (which may or may
not be the type of either a or b);
- are "close enough" to treat as if they were the same;
- represent the same abstract quantity or quality;
- have the same printable representation;
- or something else!

But note that even if one or more of these are true, it doesn't
necessarily mean that a==b will return true. "two" and "deux" both
represent the same abstract quantity, but no programming language I know
of will recognise them as equal.

And then there is this potent source of bugs:

>>> distance_in_feet = 5
>>> weight_in_milligrams = 5
>>> distance_in_feet == weight_in_milligrams
True

Since when is a distance comparable to a weight, let alone equal?


-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to