
Feb. 26, 2009
4:14 p.m.
2009/2/27 Eric Smith <eric@trueblade.com>:
Daniel Stutzbach wrote: ...
The "with" statement is great, but it results in the bulk of the code being indented twice. I'd like to propose a little syntactic sugar, the "try with":
try with something as f: many lines of code except some_error: handle error
Not commenting on how useful the proposal is (I'm mostly stuck in Python 2.4), but couldn't this be:
with something as f: many lines of code except some_error: handle error
+1 Like the OP, I find myself doing this same sequence of code over and over. The syntax you describe here would clean the code up considerably. -- "Life? Don't talk to me about life." - Marvin