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

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Apr 27 10:07:20 EDT 2012


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:

"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)

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.



-- 
Steven



More information about the Python-list mailing list