Re: [Python-ideas] Programming recommendations (PEP 8) and boolean values

9 Aug
2012
9 Aug
'12
1:22 a.m.
Taking the liberty to return this to the mailing list.
On 09/08/12 08:05, Michael Foord wrote:
Why does the PEP say that == True is preferred to is True?
Because there surely are still libraries out there that return 0 and 1 as true/false values. The bool type was introduced in (by memory) Python 2.2 or 2.3, so very old code may fail, or worse, silently do the wrong thing if you use "is True".
Surely? I haven't seen one in*years*.
Nevertheless, "return 1" is still legal Python and was once the idiomatic way of returning a flag. If you don't have a good reason to break such old code, why break it?
--
Steven
4141
Age (days ago)
4141
Last active (days ago)
0 comments
1 participants
participants (1)
-
Steven D'Aprano