3 ms·
Python's own @contextmanager decorator ( http://docs.python.org/library/contextlib.html#contextlib.contextmanager http://docs.python.org/library/contextlib.html
by praptak 16y ago
Python's own @contextmanager decorator ( http://docs.python.org/library/contextlib.html#contextlib.contextmanager http://docs.python.org/library/contextlib.html#contextlib.co... ) uses generators in quite a clever way. You can grok quite a lot about Python generators by trying to figure out what @contextmanager actually does under the hood.