Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions peps/pep-0007.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pep8-operator-linebreak>` for a longer discussion.)

* Vertically align line continuation characters in multi-line macros.

* Macros intended to be used as a statement should use the
Expand Down
3 changes: 3 additions & 0 deletions peps/pep-0008.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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?
------------------------------------------------------

Expand Down