def observation(observe, notify):
"""Simple boilerplate to link to the 'with' statement.
Contextlib's contextmanager decorator is a very convenient way to
create simple context managers, specifically the __enter__ and
__exit__ special methods.
"""
proxy = Observation(observe, notify)
try:
yield proxy
finally:
proxy.close()
评论列表
文章目录