PEP 285: Adding a bool type

Erik Max Francis max at alcyone.com
Sun Mar 31 14:09:00 EST 2002


Stefan Schwarzer wrote:

> but on the other hand have to keep in mind subtle interactions between
> bools and ints. For example, I consider it very unintutive that
> "True == 1" should by true but "True == 2" should be false.

Why?  Implicit conversions seem un-Pythonic, so why would this be
unfortunate?  When you write (True == 2) you're asking, "Is the value
true equal to the integer value 2?" the answer to which is clearly no. 
Same thing with something like (2 == "2") -- no conversions are going on
here so the test is false.

> Additionally, the PEP brings some more design ambiguity which I
> dislike. Should my function/method return 0, None, - or False, in a
> specific case?

Seems pretty clear, and it depends on what the function or method is
supposed to be computing.  If it's an object or lack-of-object, then
None.  If it's a Boolean, then True or False.  If it's an integer, then
some integer or 0.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Nationalism is an infantile sickness.
\__/ Albert Einstein
    Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html
 A new, virtual planet, every day.



More information about the Python-list mailing list