Feedback on Until recipe

Antoon Pardon apardon at forel.vub.ac.be
Thu Apr 26 06:58:12 EDT 2007


On 2007-04-24, Thomas Nelson <thn at mail.utexas.edu> wrote:
> Occasionally someone posts to this group complaining about the lack of
> "repeat ... until" in python.  I too have occasionally wished for such
> a construct, and after some thinking, I came up with the class below.
> I'm hoping to get some feedback here, and if people besides me think
> they might use it someday, I can put it on the python cookbook.  I'm
> pretty happy with it, the only ugly thing is you have to use a
> lambda.  Ideally i'd like to just see
> while Until(i<3)
> but that doesn't work.
> Please tell me what you think, and thanks for your time.

Maybe we should try to get the developers revive PEP 315.

This PEP whould introduce a do-while statement that looks
like the folowing:

  do
    statements
  while condition
    statements


this would be equivallent to:

  while 1:
    statements
    if not condition:
      break
    statements


Those wanting something like:

  repeat
    statements
  until condition


Could then write something like:

  do
    statements
  while not condition
    pass


Still not the most elegant but a vast improvement IMO.

-- 
Antoon Pardon



More information about the Python-list mailing list