3 Mar
2013
3 Mar
'13
4:36 p.m.
Stefan Behnel wrote:
The above example therefore strikes me as useless. If you need a try-except around a with block, then your context manager is doing something wrong.
A with statement is equivalent to try-finally, not try-except, so if you want to catch the exception you still need to put a try-except somewhere. However, I can't see why you're any more likely to want to put try-except directly around a with statement than any other kind of statement. So why ask for try-with in particular, and not try-if, try-while, try-for, ...? -- Greg