Thoughts on PEP315

Tim Rowe tim at remove_if_not_spam.digitig.co.uk
Tue Sep 23 16:19:12 CEST 2003


On Tue, 23 Sep 2003 04:39:14 +0100, Stephen Horne
<$$$$$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$.co.uk> wrote:

>On Mon, 22 Sep 2003 21:47:05 -0400, "John Roth"
><newsgroups at jhrothjr.com> wrote:

>>do:
>>    bibbity
>>    bobbity
>>    boo
>>    while condition  # note the lack of a colon!
>
>Yuck!!!
>
>This is really no different to the following, which is quoted in the
>PEP as something to move away from...
>
>  while True :
>    ...
>    if condition : break
>    ...
>
>The fundamental problem is that the exit point is not obvious because
>it is 'hidden' in the detail of the loop - it is a statement within
>the loop body instead of being lexically a part of the loop.

It is very different indeed.  In the second case stuff can go after
the "if condition: break", so the terminating condition is potentially
buried in the surrounding code.  On my reading of John's proposal
nothing can go after the "while condition", so the end is clearly
marked in the Python way by the indentation dropping back a level.

What I /don't/ like about it is the overloading of the "while"
keyword.  I would much sooner reverse the condition and use "until",
though I realise the back-compatibility issues of introducing new
keywords.





More information about the Python-list mailing list