Steven D'Aprano wrote: > Consider the following common exception handling idiom: > > def func(iterable): > it = iter(iterable) > try: > x = next(it) > except StopIteration: > raise ValueError("can't process empty iterable") > print(x) > > The intention is: > > * detect an empty iterator by catching StopIteration; > * if the iterator is empty, raise a ValueError; > * otherwise process the iterator. > > Note that StopIteration is an internal detail of no relevance whatsoever > to the caller. Expose this is unnecessary at best and confusing at worst.
http://mail.python.org/pipermail/python-list/2010-October/1258606.html http://mail.python.org/pipermail/python-list/2010-October/1259024.html -- http://mail.python.org/mailman/listinfo/python-list