Message273242
| Author |
ncoghlan |
| Recipients |
SilentGhost, barry, mb_, ncoghlan, rhettinger, yselivanov |
| Date |
2016年08月20日.19:18:22 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1471720703.55.0.995759162337.issue27814@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
contextlib.suppress provides a contextmanager spelling for the following pattern:
try:
<body>
except <expr>:
pass
That's a very common pattern worth having in the standard library, even though it's only a 5 line context manager.
The proposed API change would make it instead an implementation of the vastly *less* common pattern:
try:
<body>
except <unless-expr>:
raise
except <expr>:
pass
For the use case you're discussing (trying to shut down, potentially failing, but also not wanting to hide genuine programming errors), I'd be more amenable to introducing a comparable context manager to the logging module that, instead of silently ignoring caught exceptions, logged them, and also allowed you to restrict which exceptions were logged. |
|