[Python-Dev] PEP 7 and braces { .... } on if (original) (raw)
Serhiy Storchaka storchaka at gmail.com
Sat Jun 3 12:25:25 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 ]
Yet about braces. PEP 7 implicitly forbids breaking the line before an opening brace. An opening brace should stay at the end the line of the outer compound statement.
if (mro != NULL) {
...
}
else {
...
}
if (type->tp_dictoffset != 0 && base->tp_dictoffset == 0 &&
type->tp_dictoffset == b_size &&
(size_t)t_size == b_size + sizeof(PyObject *)) {
return 0; /* "Forgive" adding a __dict__ only */
}
But the latter example continuation lines are intended at the same level as the following block of code. I propose to make exception for that case and allow moving an open brace to the start of the next line.
if (type->tp_dictoffset != 0 && base->tp_dictoffset == 0 &&
type->tp_dictoffset == b_size &&
(size_t)t_size == b_size + sizeof(PyObject *))
{
return 0; /* "Forgive" adding a __dict__ only */
}
This adds a visual separation of a multiline condition from the following code.
- 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 ]