[Python-Dev] PEP 7 and braces { .... } on if
Ethan Furman
ethan at stoneleaf.us
Mon Jun 5 11:19:49 EDT 2017
> if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
> "invalid escape sequence '\\%c'",
> *first_invalid_escape) < 0) {
> Py_DECREF(result);
> return NULL;
> }
>
> What other core developers think about this?
I would format that as:
if (PyErr_WarnFormat(
PyExc_DeprecationWarning,
1,
"invalid escape sequence '\\%c'",
*first_invalid_escape) < 0)
{
Py_DECREF(result);
return NULL;
}
Because:
- 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
- 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
All in all, it becomes easier for (at least my) suboptimal eyes to read the code.
--
~Ethan~
More information about the Python-Dev
mailing list