[Python-Dev] For review: PEP 285: Adding a bool type

Guido van Rossum guido@python.org
2002年3月08日 17:44:53 -0500


> > Absolutely not. I want True == 2 to be False.
>> Interesting. so:
> 	operator.truth(2) would be True

Yes, this would do exactly the same as bool(2).
> but:
> 	2 == True would be False

Just as in C99 (the new updated C standard, not yet in actual use).
> and:
> 	bool(2) would be True
>> Once again, casting, coercion, comparisons and truth value rear their
> fuzzy heads.

For the first time, we'll have a standard way to cast an arbitrary
value to a normalized truth value. Currently we write "not not x" for
that. Now *that* is ugly.
Also, you'll be able to use 'is' and 'is not', as follows:
 if bool(x) is True: ...
 if bool(y) is not True: ...
Not that I endorse this (I still think that anybody who takes a
boolean result and then compares it to True is crazy), but it reads
like English. :-)
--Guido van Rossum (home page: http://www.python.org/~guido/)

AltStyle によって変換されたページ (->オリジナル) /