[Python-Dev] PEP 7 clarification request: braces
scott+python-dev at scottdial.com
Mon Jan 2 06:04:15 CET 2012
On 1/1/2012 11:44 PM, Nick Coghlan wrote:
> 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)
Could you explain how these two cases differ with regard to maintenance?
In either case, there are superfluous edits required if the original
author had used braces *always*. Putting a brace on one-liners adds only
a single line to the code -- just like in the if/else case. So, your
argument seems conflicted. Surely, you would think this is a simpler
edit to make and diff to see in a patch file:
Also, the superfluous edits will wrongly attribute the blame for the
conditional to the wrong author.
scott at scottdial.com
More information about the Python-Dev