Reference
Chris Angelico
rosuav at gmail.com
Tue Mar 4 10:25:57 EST 2014
On Wed, Mar 5, 2014 at 2:19 AM, Jerry Hill <malaclypse2 at gmail.com> wrote:
> Out of curiosity, do you think we should be doing truth checking with
> 'is'? True and False are singletons, and it seems to me that the
> justification for idenity versus equality should be just as strong
> there, but I don't think I've ever seen anyone even suggest that.
Normal truth testing is done like this:
if cond:
This isn't truth testing, this is checking the identity of what's in cond:
if cond is True:
And that's specifically testing for something much tighter than
truthiness. As you can see from my stats above, that's actually fairly
rare. Usually you'd just accept that True, 1, "yes", [1,2,3], and
1.2345 are all equally true.
ChrisA
More information about the Python-list
mailing list