Continuing indentation

cl at isbd.net cl at isbd.net
Thu Mar 3 05:22:41 EST 2016


codewizard at gmail.com wrote:
> On Wednesday, March 2, 2016 at 3:44:07 PM UTC-5, Skip Montanaro wrote:
> > 
> >     if (some_condition and
> >         some_other_condition and
> >         some_final_condition):
> >         play_bingo()
> 
> How about:
> 
>   continue_playing = (
>       some_condition and
>       some_other_condition and
>       some_final_condition
>   )
> 
>   if continue_playing:
>       play_bingo()
> 
> or:
> 
>   play_conditions = [
>       some_condition,
>       some_other_condition,
>       some_final_condition,
>   ]
> 
>   if all(play_conditions):
>       play_bingo()
> 
I'd much prefer the [] and () to be aligned so I can check that
beginnings have ends.  Similarly in C I prefer:-

    if ( x == y )
    {
        z = 99;
    }

rather than:-

    if ( x == y ) {
        z = 99;
    }

Apparently the second is/was only popular because it uses fewer lines
and thus more code would appear on a single screen.

-- 
Chris Green
·



More information about the Python-list mailing list