Message169343
| Author |
ncoghlan |
| Recipients |
alex, ncoghlan, rhettinger |
| Date |
2012年08月29日.06:20:48 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1346221249.34.0.835780678858.issue15806@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| 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 |
|