[Python-Dev] cpython: Remove some extraneous parentheses and swap the comparison order to

Eli Bendersky eliben at gmail.com
Tue Jun 7 11:47:13 CEST 2011

>> Swapping the comparison order here seems a bit inconsistent to me. There are
>> lots of others around (e.g. "len == 0" in the patch context below). Why is
>> this one so special?
>> I think that another developer even got told off once for these kinds of
>> comparisons.
>> I hope the Clang warning is only about the parentheses.
> I agree with Georg: "if ('u' == typecode)" is not well readable,
> since you usually put the variable part on the left and the constant
> part on the right of an equal comparison.
> If clang warns about this, clang needs to be fixed, not our
> C code :-)


Placing the constant first in a comparison is a fundamental style
issue. Personally I also don't like doing that, but whatever way is
chosen must be consistent. It's definitely wrong to change this in a
single place. We have PEP-7 for these things!

AFAIK, Clang doesn't produce a warning for this, at least without
special static-analysis warning levels.


More information about the Python-Dev mailing list