Coding style in CPython implementation
ROGER GRAYDON CHRISTMAN
dvl at psu.edu
Sun Oct 29 19:28:36 EDT 2017
NOTE: The case in question was never comparing to True; it was comparing to
NULL.
There is no "No: if x == None" below, because None is not Boolean.
Similarly comparing a pointer to NULL is not the same as comparing it to a
Boolean.
So I would favor the "Explicit is better than Implicit" in the example cited.
Roger Christman
Pennsylvania State University
On Sun, Oct 29, 2017, Setfan Ram wrote: >
=?UTF-8?B?zqPPhM6tz4bOsc69zr/PgiDOo8+Jz4bPgc6/zr3Or86/z4U=?=
<stefanossofroniou542 at gmail.com> writes:
>>I guess the following parts from "Zen of Python" apply to this case:
>
> If we would agree to apply Python rules to C,
> then we could also use this excerpt from PEP 8:
>
>|o Don't compare boolean values to True or False using ==.
>|
>|Yes: if greeting:
>|No: if greeting == True:
>|Worse: if greeting is True:
>
>
More information about the Python-list
mailing list