[Python-Dev] PEP 7 clarification request: braces

Nick Coghlan ncoghlan at gmail.com
Mon Jan 2 11:15:25 CET 2012

On Mon, Jan 2, 2012 at 6:47 PM, Raymond Hettinger
<raymond.hettinger at gmail.com> wrote:
> Really?  Do we need to have a brace war?
> People have different preferences.
> The standard library includes some of both styles
> depending on what the maintainer thought was cleanest to their eyes in a given context.

If the answer is "either form is OK", I'm actually fine with that (and
will update PEP 7 accordingly). However, I have long read PEP 7 as
*requiring* the braces, and until noticing their absence in some of
Benjamin's checkins and the recent conflicting advice we gave when
reviewing the same patch, I had never encountered their absence in the
CPython code base outside the one-liner/two-liner case*.

Since I *do* feel strongly that leaving them out is a mistake that
encourages future defects, and read PEP 7 as agreeing with that (aside
from the general "follow conventions in surrounding code" escape
clause), I figured it was better to bring it up explicitly and clarify
PEP 7 accordingly (since what is currently there is clearly ambiguous
enough for two current committers to have diametrically opposed views
on what it says).


* That is, constructs like:

  if (error_condition) return -1;

  if (error_condition)
    return -1;

Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list