[Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore().
Zero Piraeus
z at etiol.net
Tue Oct 15 20:02:15 CEST 2013
:
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
More information about the Python-Dev
mailing list