diff --git a/peps/pep-0007.rst b/peps/pep-0007.rst index bcad808ee..f85ef7182 100644 --- a/peps/pep-0007.rst +++ b/peps/pep-0007.rst @@ -140,20 +140,24 @@ Code lay-out "cannot create '%.100s' instances", type->tp_name); -* When you break a long expression at a binary operator, the - operator goes at the end of the previous line, and braces should be - formatted as shown. E.g.: +* When you break a long expression at a binary operator, braces + should be formatted as shown: .. code-block:: :class: good - if (type->tp_dictoffset != 0 && base->tp_dictoffset == 0 && - type->tp_dictoffset == b_size && - (size_t)t_size == b_size + sizeof(PyObject *)) + 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 */ } + It's OK to put operators at ends of lines, especially to be + consistent with surrounding code. + (See :ref:`PEP 8 ` for a longer discussion.) + * Vertically align line continuation characters in multi-line macros. * Macros intended to be used as a statement should use the diff --git a/peps/pep-0008.rst b/peps/pep-0008.rst index 783093c98..087370fed 100644 --- a/peps/pep-0008.rst +++ b/peps/pep-0008.rst @@ -257,6 +257,9 @@ Another such case is with ``assert`` statements. Make sure to indent the continued line appropriately. + +.. _`pep8-operator-linebreak`: + Should a Line Break Before or After a Binary Operator? ------------------------------------------------------