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-June/148256.html below:

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

[Python-Dev] PEP 7 and braces { .... } on ifEthan Furman ethan at stoneleaf.us
Wed Jun 7 00:45:00 EDT 2017
On 06/06/2017 05:30 PM, Barry Warsaw wrote:
> On Jun 05, 2017, at 08:19 AM, Ethan Furman wrote:

>> I would format that as:
>>
>>           if (PyErr_WarnFormat(
>>                   PyExc_DeprecationWarning,
>>                   1,
>>                   "invalid escape sequence '\\%c'",
>>                   *first_invalid_escape) < 0)
>>               {
>>               Py_DECREF(result);
>>               return NULL;
>>           }
>
> In this case I'd *still* indent the opening brace to under the `if`.  The
> mismatched indentation between the open and close braces is jarring to me.
>
>> - having all the arguments on separate lines means
>>    - the function and first argument don't get run together
>>    - it's easy to pick out the individual arguments
>
> That's fine with me, but so is hanging the arguments, so I'd tend to leave
> this up to the individual devs.
>
>> - having the opening brace on its own line means
>>    - a little extra white space to buffer the condition and the body
>>    - it's easier to read the function name and then drop down to the
>>      body
>
> Agreed with the rationale for the open brace being on a separate line, but did
> you mean to indent the opening and closing braces to different levels?

It's what I see.  Left to my own devices I would leave the opening brace where it is and indent the closing brace to 
match.  That way when I see code at the same level as the opening `if` I know I'm out of that block.

--
~Ethan~

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