Re: getting with statement to deal with various exceptions

2008-07-20 Thread mk
from __future__ import with_statement class ExceptionManager(object): def __enter__(self): pass def __exit__(self,exc_type,exc_value,tb): if exc_type == IOError: print 'IOError',exc_value[1] return True # suppress it wi

Re: getting with statement to deal with various exceptions

2008-07-20 Thread Mark Tolonen
"mk" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, I'm trying to learn how with statement can be used to avoid writing: prepare() try: something_that_can_raise_SomeException() except SomeException, err: deal_with_SomeException finally: tear_it_down() Verbose, not very re

getting with statement to deal with various exceptions

2008-07-20 Thread mk
Hello, I'm trying to learn how with statement can be used to avoid writing: prepare() try: something_that_can_raise_SomeException() except SomeException, err: deal_with_SomeException finally: tear_it_down() Verbose, not very readable. OK, "with" to the rescue? Let's tak