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

> try:
>     f = open(path)
> except Whatever:
>     handle_error()
> else:
>     with f:
>         do_stuff()

That's cool. Never really used try-else.

> That gets old really quickly! But then, handling errors is always the
> ugliest part of coding. Hiding the messy details inside a function is
> often a good idea.

There's no way around it; life is messy.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to