Op 04-03-14 16:25, Chris Angelico schreef: > On Wed, Mar 5, 2014 at 2:19 AM, Jerry Hill <malaclyp...@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:
In an other language with real booleans where an if only accepts a boolean that would be true. In python this is testing for "something." > 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. No I usually don't accept that. A number different from 0 is not the same as a none-empty list. I usally don't want to treat them the same. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list