Nick Coghlan added the comment:

I'd just write it with @contextmanager. Making it easier to cleanly factor out 
exception handling is one of the main reasons that exists.

  @contextmanager
  def ignored(*exceptions):
    """Context manager to ignore particular exceptions"""
    try:
        yield
    except exceptions:
        pass

While the class based version would likely be fractionally faster, the 
generator based version is more obviously correct.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15806>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to