[Python-Dev] PEP 7 clarification request: braces

Antoine Pitrou solipsis at pitrou.net
Mon Jan 2 13:05:28 CET 2012


On Mon, 2 Jan 2012 14:44:49 +1000
Nick Coghlan <ncoghlan at gmail.com> wrote:
> 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;
>   }

Good, I was afraid python-dev was getting a bit futile with all these
security concerns about hash functions.

I don't like having the else on the same line as the closing brace,
and prefer:

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

That said, I agree with Benjamin: the shorter form is visually lighter
and should not be frown upon.

Regards

Not-frowning Antoine.




More information about the Python-Dev mailing list