why () is () and [] is [] work in other way?

Kiuhnm kiuhnm03.4t.yahoo.it
Fri Apr 27 11:24:08 EDT 2012


On 4/27/2012 16:07, Steven D'Aprano wrote:
> On Fri, 27 Apr 2012 14:17:48 +0200, Kiuhnm wrote:
>
>>>> Define your terms: what do you mean by "equal"?
>>>
>>> a and b are equal iff
>>
>> Nope. What I meant is that we can talk of equality whenever...
>>
>>> a = a
>>> a = b =>  b = a
>>> a = b and b = c =>  a = c
>>> If some of this properties are violated, we're talking of something
>>> else.
>
> Sorry, that won't do it. You haven't defined equality, or given any way
> of deciding whether two entities are equal. What you have listed are
> three *properties* of equality, namely:
>
> - reflexivity (a = a)
> - symmetry (if a = b then b = a)
> - transitivity (if a = b and b = c then a = c)
>
> But those three properties apply to any equivalence relation, not just
> equality. Examples:

But that's what equality is in programming languages.
You choose whatever you want. Just abide to those rules.

> "both are odd" (of integers)
> "have the same birthday" (of people)
> "is congruent to" (of triangles)
> "is in the same tax bracket" (of tax payers)
> "has the same length" (of pieces of string)
> "both contain chocolate" (of cakes)

I can very well define a class Z_2 where 1 and 3 are equal (both are 
odd) and equality is defined as
   x % 2 == y % 2

This is why I keep saying that asking what 'equal' means lead us nowhere.
Equality is whatever you see fit as long as you follows some rules.

> For example, if we define the operator "~" to mean "has the same
> genes" (to be precise: the same genotype), then if Fred and Barney are
> identical twins we have:
>
> Fred ~ Fred
> Fred ~ Barney and Barney ~ Fred
>
> Identical triplets are rare (at least among human beings), but if we
> clone Barney to get George, then we also have:
>
> Fred ~ Barney and Barney ~ George =>  Fred ~ George.
>
> So "have the same genes" meets all your conditions for equality, but
> isn't equality: the three brothers are very different. Fred lost his arm
> in a car crash, Barney is a hopeless alcoholic, and George is forty years
> younger than his two brothers.

/You/ decide if '~' is a good definition for equality in your case.
If it isn't, then define it another way.
What I'm saying is that equality is in the eye of the beholder.
To me, in some situations, all odd numbers are the same. What's wrong 
with that?

Kiuhnm



More information about the Python-list mailing list