Skip to main content

Python gets a new ignored context manager

I was reading What makes Python Awesome? presentation and saw the following construction in slide 22:

with ignore(OSError):

This construction is more concise without being less readable than the typical try ... catch ... pass. I had never seen that ignore before and got curious about where is it defined. It isn’t a CPython keyword neither part of the contextlib module.

After some search I found that an ignored (note the trailing d) context manager was recently added to the upcoming python 3.4.