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

Guido van Rossum guido at python.org
Tue Jun 7 23:11:41 CEST 2011


On Tue, Jun 7, 2011 at 2:47 AM, Eli Bendersky <eliben at gmail.com> wrote:
>>> 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 :-)
>>
>
> +1
>
> 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!

Right. I personally really despise putting the constant first.

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

CLang shouldn't force our hand here.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list