PEP 285: Adding a bool type

Alex Martelli aleax at aleax.it
Thu Apr 4 01:28:09 EST 2002


Chris Liechti wrote:
        ...
> 6 == True and 7 == True does _not_ infer 6 == 7. when using an 'if' nobody

Sure does, IF == has its fundamental mathematical properties: reflexive,
symmetric, transitive.  If it doesn't, then it does not even define an 
equivalence relationship among objects -- an absurd issue for the
concept of "equality".

Pragmatically, among other absurdities, such an == would imply that
booleans are not hashable, as otherwise x==y -> hash(x)==hash(y)
and hash(True) cannot equal both hash(6) AND hash(7).  Or else
you'd have to revolutionize the definition of hash vs eq and the whole
set of concepts underlying dictionaries.  Thinking of what this would
imply for < and > is also fun (presumably you'd have to make bools
non-comparable, like complex numbers -0- what fun!).

I think this detail of your proposal is really balmy.


Alex




More information about the Python-list mailing list