[OT] Python indentation

bruno modulix onurb at xiludom.gro
Wed Jul 7 16:16:32 EDT 2004


Reinhold Birkenfeld a écrit :
> Grant Edwards wrote:
> 
(snip about 'why significative whitespace')
>>>
>>>Yes. It's about readability.
>>>
(snip)
>>Compare C and Python:
>>
>>In C, we have 10 lines
>>
>>  if (condition)
>>    {
>>      doThis();
>>      doThat();
>>    }
>>  else
>>    {
>>      doWhatever();
>>      andSoOn();      
>>    }    
> 
> 
> Well, one could apply another coding style in this example:
> 
> if (condition) {
>   doThis();
>   doThat();
> } else {
>   doWhatever();
>   andSoOn();
> }
> 
> which only takes 7 lines and is not much less readable. 

For me it's as absolutely unreadable as the first snippet.
The only truely correct layout being (of course !-) :

if (condition)
{
     doThis();
     doThat();
}
else
{
     doWhatever();
     andSoOn();
}

> But I agree with
> you!

I do too. The fact is that there is no brace-and-indent-style-war with 
Python !-)

Bruno



More information about the Python-list mailing list