Thoughts on PEP315

John Roth newsgroups at jhrothjr.com
Tue Sep 23 12:38:45 EDT 2003


"Tim Rowe" <tim at remove_if_not_spam.digitig.co.uk> wrote in message
news:t2l0nv8914nfnmbtl65265sfut8dujt40f at 4ax.com...
> 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.

Thanks, Terry. That's exactly what I meant to convey.

> 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.

That's always a problem, although my understanding of the
objectives for 2.4 is that there will probably be a number of
new keywords, so one more won't make a significant
difference. 2.3 was supposed to avoid adding them.

My major objection is that I don't think there's enough usage
to justify the additional complexity, regardless of whether we
can come up with a clean, Pythonic way of expressing it.

John Roth
>






More information about the Python-list mailing list