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

   with ExceptionManager():
       with open('test.txt') as f:
           f.read()

Neat. I think I'm going to use this approach, since BDFL-in-chief is unlikely to listen to me in any foreseeable future. :-)

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to