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

2017年6月05日 08:22:11 -0700

 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~
_______________________________________________
Python-Dev mailing list
[email protected]
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