On Tue, 21 Jun 2005 12:05:25 +0200, Magnus Lycka <[EMAIL PROTECTED]> wrote: > Remi Villatel wrote: >> while True: >> some(code) >> if final_condition is True: >> break >> # >> # >> >> What I don't find so "nice" is to have to build an infinite loop only to >> break it. > > This is a common Python idiom. I think you will get used to it. > > >> Is there a better recipe? > > final_condition = False > while not final_condition: > some(code)
To the OP, don't get hung up on the syntax we use to implement a loop. I took my first programming class long enough ago that we had to do things like this (roughly translating the FORTRAN IV I remember into p-code) To do: while TrueCondition (loop body) we'd have to write: TopOfLoop: if not TrueConditional goto loopEnd (loop body) goto TopOfLoop loopEnd: We were even required to write our source twice: The first pass was "structured" and had to be proven correct. The second pass was translated into something our compiler supported. We still called it a "while loop" even though the syntax was icky. When C came out with its built in looping, it was an unbelievable luxury. -- http://mail.python.org/mailman/listinfo/python-list