[Python-Dev] PEP 7 clarification request: braces

Nick Coghlan ncoghlan at gmail.com
Mon Jan 2 05:44:49 CET 2012


I've been having an occasional argument with Benjamin regarding braces
in 4-line if statements:

  if (cond)
    statement;
  else
    statement;

vs.

  if (cond) {
    statement;
  } else {
    statement;
  }

He keeps leaving them out, I occasionally tell him they should always
be included (most recently this came up when we gave conflicting
advice to a patch contributor). He says what he's doing is OK, because
he doesn't consider the example in PEP 7 as explicitly disallowing it,
I think it's a recipe for future maintenance hassles when someone adds
a second statement to one of the clauses but doesn't add the braces.
(The only time I consider it reasonable to leave out the braces is for
one liner if statements, where there's no else clause at all)

Since Benjamin doesn't accept the current brace example in PEP 7 as
normative for the case above, I'm bringing it up here to seek
clarification.

Cheers,
Nick.

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


More information about the Python-Dev mailing list