This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年08月29日 01:37 by gd2shoe, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg169326 - (view) | Author: (gd2shoe) | Date: 2012年08月29日 01:37 | |
I'm constantly finding myself writing itty-bitty try blocks like such: process stuff try : someSubProcess.kill() except : pass process stuff I realize this isn't a rigorous use of except, but it's good enough for a vast majority of what I need it for. Still, it adds excess verbiage and makes code slightly harder to read. All I need except to do most of the time is suppress exceptions. I think the language could be enhanced by making the except clause implicit. the above would become: process stuff try : someSubProcess.kill() process stuff The intent remains clear. The code is cleaner and easier to read. This does not happen often in rigorous code, but grep does find 3 counts in standard modules and 9 counts in numpy. I'm certain most prototype code (like mine) would greatly benefit. (My current 300 line project uses 4 so far.) |
|||
| msg169327 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2012年08月29日 01:45 | |
FWIW, this is already easy to do with decorators: >>> class Pass: def __init__(self, exc): self.exc = exc def __enter__(self): return self def __exit__(self, exctype, excinst, exctb): return exctype == self.exc >>> with Pass(IndexError): 'hello'[10] |
|||
| msg169328 - (view) | Author: Jesús Cea Avión (jcea) * (Python committer) | Date: 2012年08月29日 01:52 | |
No way this is going to be in 2.7. |
|||
| msg169331 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2012年08月29日 03:04 | |
Please submit your idea to the python-ideas list. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:35 | admin | set | github: 60008 |
| 2012年08月29日 06:54:14 | ezio.melotti | set | stage: resolved |
| 2012年08月29日 03:04:23 | benjamin.peterson | set | status: open -> closed nosy: + benjamin.peterson messages: + msg169331 resolution: wont fix |
| 2012年08月29日 01:52:43 | jcea | set | nosy:
+ jcea messages: + msg169328 versions: - Python 2.7 |
| 2012年08月29日 01:45:17 | rhettinger | set | priority: normal -> low nosy: + rhettinger messages: + msg169327 |
| 2012年08月29日 01:37:15 | gd2shoe | create | |