math.nroot

Mike Meyer mwm at mired.org
Mon Jul 4 13:37:32 EDT 2005


"George Sakkis" <gsakkis at rutgers.edu> writes:
> "Steven D'Aprano" <steve at REMOVEMEcyber.com.au> wrote:
>
>> But it doesn't make sense to say that two flags are equal:
>>
>> keep_processing = True
>> more_reading_needed = True
>> while more_reading_needed and keep_processing:
>>      get_more_records()
>>      process_records()
>> if not keep_processing:
>>      print "User clicked Cancel"
>>
>> What does it mean to say that the flag done_processing
>> is equal to the flag more_reading_needed? (That is not
>> the same question as asking if the two flags have the
>> same value.)
>
> Huh ? Equality *is* the answer to whether two "things" (flags or
> whatever) have the same value or not.

I think it seriously depends on what your "things" are.

For instance:

    length_in_meters = 1
    length_in_feet = 3.2808399

The two variables clearly have different values. Yet they are also
clearly equal - representing a distance of 1 meter, within tolerances.

On the other hand:

   length_in_meters = 1
   time_in_days = 1

These two variables clearly have the same value. Yet they aren't
equal. In fact, comparing them is clearly an error. Not one that most
languages will catch, admittedly, but still an error.

Actually, I would have reversed the senses of "equal" and "having the
same value". But I think this shows that the two concepts are not the
same thing. This is why Python lets you provide classes with
custom comparison operators. So you can make the syntactic test for
"equal" mean "has the same value", even if that's not what the
native/naive implementation of comparison would do.

          <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list