Coding style in CPython implementation
Ned Batchelder
ned at nedbatchelder.com
Sat Oct 28 16:06:49 EDT 2017
On 10/28/17 3:00 PM, Stefan Ram wrote:
> =?UTF-8?B?zqPPhM6tz4bOsc69zr/PgiDOo8+Jz4bPgc6/zr3Or86/z4U=?= <stefanossofroniou542 at gmail.com> writes:
>> What I wanted to ask is, is there a particular reason for not choosing
> I am not a CPython developer, but here are my 2 cents about
> the possibilities:
>
>> if (variable == NULL) { ... }
>> if (!variable) { ... }
> »!variable« is clearer, because it does not depend on the
> definition of »NULL«. »NULL« is not part of the C language proper.
Especially if NULL is not part of the standard, then you need to write
"variable == NULL", since "!variable" may not have the same effect after
"return NULL;" depending on how NULL is defined.
>
> (I sometimes like to write »if( variable ); else { ... }«.)
Ick.
--Ned.
More information about the Python-list
mailing list