Exception handling in Python 3.x

Ethan Furman ethan at stoneleaf.us
Mon Dec 13 15:46:31 EST 2010


Arnaud Delobelle wrote:
> 
> I missed the start of this discussion but there are two simpler ways:
> 
> def func(iterable):
>     for x in iterable:
>         print(x)
>         return
>     raise ValueError("... empty iterable")


For the immediate case this is a cool solution.

Unfortunately, it doesn't fix the unwanted nesting of exceptions problem.

~Ethan~



More information about the Python-list mailing list