Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> writes:

> 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)

Not exactly what you're looking for, but another way to express the
above is:

def func(iterable):
    for x in iterable:
        break
    else:
        raise ValueError("can't process empty iterable")
    print(x)

Otherwise, I completely agree that being unable to completely replace
the original exception is an annoyance at best.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to