davidhalter/jedi — pull request #202 by dbrgn (2013-04-17 21:35:26+00:00)
Title: New "with ignored(*exceptions)" context manager

One of the best things in [this talk](pyvideo.org/video/1780/transforming-code-into-beautiful-idiomatic-pytho) is the `ignored(*exceptions)` context manager. I immediately grepped my projects and saw that Jedi can be improved by this -> 51 additions and 73 deletions :)

```
+@contextlib.contextmanager
+def ignored(*exceptions):
+ """Context manager that ignores all of the specified exceptions. This will
+ be in the standard library starting with Python 3.4."""
+ try:
+ yield
+ except exceptions:
+ pass
```

Watching the linked talk is recommended.

PS: The `ignored` context manager will be in Python 3.4's stdlib.