No, loop-and-a-half! (Re: REPEAT... UNTIL ?)

Andrew Clover and-google at doxdesk.com
Fri Jul 12 05:47:57 EDT 2002


Thomas Bellman <bellman at lysator.liu.se> wrote:

> I *would* have liked that to be
> 
>     repeat:
> 	part_1()
>     while test_1():
> 	part_2()
>     while test_2():
> 	part_3()

> in Python, but that is unfortunately not compatible with the
> current Python syntax. :-(

I like that kind of syntax. I'd like to propose an alternative
keyword:

  while cond1:
    dofoo()
  andwhile cond2:
    dobar()

with an analogous structure:

  if cond1:
    dofoo()
  andif cond2:
    dobar()
  else:
    doqux()

where foo is done if cond1, bar is done if (cond1 and cond2) and qux
is done if not (cond1 and cond2). For consistency with elif it could
be called anif instead?

-- 
Andrew Clover
mailto:and at doxdesk.com
http://and.doxdesk.com/



More information about the Python-list mailing list