ACCEPTED: PEP 285
Andrew Koenig
ark at research.att.com
Sat Apr 6 21:26:08 EST 2002
djw> Pardon my ignorance (I've only been working with Python for a short
djw> while), but I don't understand why an idiom like:
djw> if x == True:
djw> would be/should be an error (or warning initially). I see C/C++ code
djw> like this all the time:
djw> bool x;
djw> x = Foo(Bar);
djw> if (x==true)
djw> {...
In C++, you've fixed the type of x when you wrote "bool x;",
so x can be only true of false.
The nearest equivalent in Python would be
if bool(x) == True:
which has no particular problems aside from being needlessly verbose.
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list