: 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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com