gd2shoe | 29 Aug 2012 03:37
Favicon

[issue15804] Feature request, implicit "except : pass"


New submission from gd2shoe:

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.)

----------
components: Interpreter Core
(Continue reading)

Raymond Hettinger | 29 Aug 2012 03:45
Favicon

[issue15804] Feature request, implicit "except : pass"


Raymond Hettinger added the comment:

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]

----------
nosy: +rhettinger
priority: normal -> low

_______________________________________
Python tracker <report <at> bugs.python.org>
<http://bugs.python.org/issue15804>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/python-python-bugs-list%40m.gmane.org

(Continue reading)

Jesús Cea Avión | 29 Aug 2012 03:52
Favicon

[issue15804] Feature request, implicit "except : pass"


Jesús Cea Avión added the comment:

No way this is going to be in 2.7.

----------
nosy: +jcea
versions:  -Python 2.7

_______________________________________
Python tracker <report <at> bugs.python.org>
<http://bugs.python.org/issue15804>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/python-python-bugs-list%40m.gmane.org

Benjamin Peterson | 29 Aug 2012 05:04
Favicon

[issue15804] Feature request, implicit "except : pass"


Benjamin Peterson added the comment:

Please submit your idea to the python-ideas list.

----------
nosy: +benjamin.peterson
resolution:  -> wont fix
status: open -> closed

_______________________________________
Python tracker <report <at> bugs.python.org>
<http://bugs.python.org/issue15804>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/python-python-bugs-list%40m.gmane.org

Ezio Melotti | 29 Aug 2012 08:54
Favicon

[issue15804] Feature request, implicit "except : pass"


Changes by Ezio Melotti <ezio.melotti <at> gmail.com>:

----------
stage:  -> committed/rejected

_______________________________________
Python tracker <report <at> bugs.python.org>
<http://bugs.python.org/issue15804>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/python-python-bugs-list%40m.gmane.org


Gmane