PEP 285: Adding a bool type
Bengt Richter
bokr at oz.net
Mon Apr 1 17:33:15 EST 2002
On Mon, 01 Apr 2002 11:28:12 -0800, Erik Max Francis <max at alcyone.com> wrote:
[...]
>> 2 Or, as the PEP suggests, introduce a bool type which behaves quite
>> unintuitive, but keeps existing programs running.
>
>I don't see why you think the behavior (I presume you're referring to
>syntaxes like True == 2) is counterintuitive. Why _would_ you expect
>this to do what you want? It doesn't for any other Python types that
>I'm aware of. == tests for equality, it doesn't do automatic type
>coercion.
>
Well, for types that are related in certain ways ... ;-)
>>> 0 == 0.0
1
>>> 1 == 1.0
1
>>> 1 == 2.0
0
That gets into what relational operators really should mean.
I think I exclude bool from the number tree, so I don't
like the effect of subtyping bool from int, even though
I support context-dependent implicit conversions to integer
(though that context should be defined by the client expression ops).
Regards,
Bengt Richter
More information about the Python-list
mailing list