[Python-Dev] PEP 7 and braces { .... } on if (original) (raw)
Ethan Furman ethan at stoneleaf.us
Mon Jun 5 11:19:49 EDT 2017
- Previous message (by thread): [Python-Dev] PEP 7 and braces { .... } on if
- Next message (by thread): [Python-Dev] PEP 7 and braces { .... } on if
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
if (PyErrWarnFormat(PyExcDeprecationWarning, 1, "invalid escape sequence '\%c'", *firstinvalidescape) < 0) { PyDECREF(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
- Previous message (by thread): [Python-Dev] PEP 7 and braces { .... } on if
- Next message (by thread): [Python-Dev] PEP 7 and braces { .... } on if
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]