[Python-Dev] Re: PEP 285: Adding a bool type
Chris Liechti
cliechti at gmx.net
Wed Apr 3 14:33:03 EST 2002
Ka-Ping Yee <ping at lfw.org> wrote in news:mailman.1017857237.27591.python-
list at python.org:
> [*] By real booleans, i mean the following. (Booleans would have
> to behave like this for me to consider them "good enough" to
> be better than what we have now.)
>
> >>> False, repr(False), str(False)
> (False, 'False', 'False')
> >>> True, repr(False), str(False)
> (True, 'False', 'False')
> >>> False + True
> TypeError...
or better "True" (0+1==1 --> True)
> >>> False == None
> 0
> >>> False == 0
> 0
> >>> True == 1
> 0
i disagree. comparing True/False with other values should give the same
result as when it were used with an 'if':
>>> True == 1, True == 6
True, True
>>> False == 0, Flase == [], Flase == 1
True, True, False
because 0 and [] etc. are representing Flasehood they should also be equal
to False. 'False is []' etc. will allways be False except for "False is
False".
> >>> {0: 0, False: False, 1: 1, True: True}
> {0: 0, False: False, 1: 1, True: True}
>
> ... and probably
>
> >>> None < False < True < 0
> True
None has no value in a nummerical sense an the docs clearly say that you
shouldn't use it that way...
False and True should be represented as 0 and 1 in a nummerical usage.
> (Hee hee -- i suppose the fact that "boolean" starts with a "b"
> gets us this for free. But i wonder how many people are going
> to be puzzled by True < 0?)
--
Chris <cliechti at gmx.net>
More information about the Python-list
mailing list