Python indentation
David Fraser
davidf at sjsoft.com
Fri Jul 9 05:44:56 EDT 2004
Antoon Pardon wrote:
> Op 2004-07-08, Christopher T King schreef <squirrel at WPI.EDU>:
>
>>On 8 Jul 2004, Antoon Pardon wrote:
>>
>>
>>>Well personnaly if i have a loop with the terminating condition
>>>in the middle I now have to write it like this
>>>
>>>while True:
>>> code
>>> if condition: break
>>> code
>>>
>>>
>>>I would prefer to indent sucu code as follows:
>>>
>>>while True:
>>> code
>>>if condition: break
>>> code
>>>
>>>
>>>Why? because the loopbreaker is IME part of the loopstructure,
>>>not an ordinary if statement in the loopbody.
>>
>>Then perhaps you'd be interested in PEP 315:
>>
>>do:
>> code
>>while not condition:
>> code
>
>
> Yes, and I would also be interested in an other proposal
> that went something like:
>
> while condition1:
> code
> and while condition2:
> code
> and while condition3:
> code
>
> maybe we should combine them into something like
>
> do:
> code
> and while condition1:
> code
> and while condition3:
> code
>
The trouble like this is I can't see what it means... it actually reads
like concurrent execution - 'do this and this and this...'
So I don't think its very readable...
David
More information about the Python-list
mailing list