PEP 285: Adding a bool type

Andreas Kostyrka andreas at mtg.co.at
Thu Apr 11 03:03:45 EDT 2002


On Mon, 01 Apr 2002 18:46:02 GMT
Alexis Layton <alexis.layton at post.harvard.edu> wrote:

> As for int-compatibility, were we designing Python from the ground up
> it might be the case that it should be designed as a pure truth type. 
> But we are constrained by Pythons 1-2.2.x so True has to be
> truly-comparable to 1.
Nope. It must be truly-comparable to any non-zero object. As it happens this is what Python uses now as definition of Truth :)
False OTOH must truly-comparable to ["",u"",None,{},[]] (and whatever I've just forgot).

I personally have often written code that uses one variable to double as "boolean indicator" and "value storage":

founditem=None
while not founditem:
	....
	if ....:
		founditem="VALUE"

print "Found item with value:",founditem

Andreas





More information about the Python-list mailing list