[Python-Dev] PEP 7 clarification request: braces (original) (raw)
Scott Dial scott+python-dev at scottdial.com
Mon Jan 2 06:04:15 CET 2012
- Previous message: [Python-Dev] PEP 7 clarification request: braces
- Next message: [Python-Dev] PEP 7 clarification request: braces
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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:
if(cond) { stmt1;
- stmt2; }
vs.
-if(cond) +if(cond) { stmt1;
- stmt2; +}
Also, the superfluous edits will wrongly attribute the blame for the conditional to the wrong author.
-- Scott Dial scott at scottdial.com
- Previous message: [Python-Dev] PEP 7 clarification request: braces
- Next message: [Python-Dev] PEP 7 clarification request: braces
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]