On 31 May 2017 at 15:11, Victor Stinner <victor.stin...@gmail.com> wrote:
> So I would suggest to modify the PEP 7 to *always* require braces for if.
>
> I would also suggest to require braces on "for(...) { ... }" and
> "while(...) { ... }". But only if the code has to be modified, not
> only to update the coding style.
>
> Changes which are pure coding style changes should be rejected to
> avoid conflicts with other pending pull requests and "code churn".

As a practical compromise, I'd argue that if you're changing
*existing* code, you should retain the current style. For *new* code,
always add braces. So, changing

if (func == NULL)
    return NULL;
/* further code */

to

if (func1 == NULL)
    return NULL;
/* further code */

you would leave out the braces. But changing

/* Code using func */

to

if (func == NULL) {
    return NULL;
}
/* Code using func */

you include the braces, because it's new code.

I'm not against making the PEP mandate braces, but I don't think it's
necessary to resolve the situation you describe as having triggered
the suggestion :-)

Paul
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to