Miki a écrit : > Hello Arnaud, > > >>Imagine I have three functions a(x), b(x), c(x) that each return >>something or raise an exception. Imagine I want to define a function >>that returns a(x) if possible, otherwise b(x), otherwise c(x), >>otherwise raise CantDoIt. > > Exceptions are for error handling, not flow control.
def until(iterable,sentinel): for item in iterable: if item == sentinel: raise StopIteration yield item >>> for item in until(range(10), 5): ... print item ... 0 1 2 3 4 >>> Exceptions *are* a form of flow control. -- http://mail.python.org/mailman/listinfo/python-list