: On Tue, Oct 15, 2013 at 09:45:59AM -0700, Ethan Furman wrote: > [...] if the CM provides the value before, and the with block accepts > it, it can then have the exception added to it: > > with trap(OSError) as cm: > os.unlink('missing.txt') > if cm.exc: > do_something() Is there some advantage to this over try: os.unlink('missing.txt') except OSError as exc: do_something() I thought the whole point was to replace code that would otherwise contain 'except: pass' with something slightly more concise. Once you expose the exception, it becomes just an uglier version of a try/except block, as far as I can see. -[]z. -- Zero Piraeus: pons asinorum http://etiol.net/pubkey.asc
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4