Message169343
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. |
|
Date |
User |
Action |
Args |
2012-08-29 06:20:49 | ncoghlan | set | recipients:
+ ncoghlan, rhettinger, alex |
2012-08-29 06:20:49 | ncoghlan | set | messageid: <1346221249.34.0.835780678858.issue15806@psf.upfronthosting.co.za> |
2012-08-29 06:20:48 | ncoghlan | link | issue15806 messages |
2012-08-29 06:20:48 | ncoghlan | create | |
|