Antoon Pardon <[EMAIL PROTECTED]> writes: > Suppose one has the following intention in mind: > > while x = setup(): > if y = pre_process() in ErrorCondition: > break > post_process(y) > else: > NormalTermination()
Maybe we need a new itertools function: def forever(func, *args, **kw): while True: yield func(*args, **kw) then you'd write: for x in takewhile(bool, forever(setup)): if y = pre_process() in ErrorCondition: break post_process(y) else: NormalTermination() It might be preferable to write pre_process to raise an exception if there's an error condition. Then the whole thing becomes: try: for x in takewhile(bool, forever(setup)): post_process(pre_process()) NormalTermination() except PreprocessError: pass -- http://mail.python.org/mailman/listinfo/python-list