[Python-ideas] Programming recommendations (PEP 8) and boolean values
Steven D'Aprano
steve at pearwood.info
Thu Aug 9 03:22:45 CEST 2012
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
More information about the Python-ideas
mailing list