[Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as

Terry Reedy tjreedy at udel.edu
Tue Feb 26 16:01:21 CET 2013


On 2/25/2013 6:53 PM, Greg Ewing wrote:
> Barry Warsaw wrote:
>>     >>> Colors = make('Colors', 'red green blue'.split())
>>     >>> Animals = make('Animals', 'ant bee cat'.split())
>>     >>> Colors.green == Animals.bee
>
> The currently suggested solution to that seems to be to
> make comparison non-transitive, so that Colors.green == 1
> and Animals.bee == 1 but Colors.green != Animals.bee.
> And then hope that this does not create a quantum black
> hole that sucks us all into a logical singularity...

But it will;-).
To repeat myself, transitivity of equality is basic to thought, logic, 
and sets and we should not deliver Python with it broken. (The 
non-reflexivity of NAN is a different issue, but NANs are intentionally 
insane.)

Decimal(0) == 0 == 0.0 != Decimal(0) != Fraction(0) == 0
was a problem we finally fixed by making integer-valued decimals
compare equal to the same valued floats and fractions. In 3.3:

 >>> from decimal import Decimal as D
 >>> from fractions import Fraction as F
 >>> 0 == 0.0 == D(0) == F(0)
True

http://bugs.python.org/issue4087
http://bugs.python.org/issue4090
explain the practical problems. We should NOT knowingly go down this 
road again. If color and animal are isolated from each other, they 
should each be isolated from everything, including int.

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list