A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-May/148087.html below:

[Python-Dev] PEP 7 and braces { .... } on if

[Python-Dev] PEP 7 and braces { .... } on if [Python-Dev] PEP 7 and braces { .... } on ifPaul Moore p.f.moore at gmail.com
Wed May 31 11:23:50 EDT 2017
On 31 May 2017 at 15:11, Victor Stinner <victor.stinner at 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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4