@contextlib question
Neal Becker
ndbecker2 at gmail.com
Fri Nov 7 14:04:47 EST 2008
http://www.python.org/doc/2.5.2/lib/module-contextlib.html has this example:
from contextlib import contextmanager
@contextmanager
def tag(name):
print "<%s>" % name
yield
print "</%s>" % name
contexlib.contextmanager doc string (2.5.1) says:
Typical usage:
@contextmanager
def some_generator(<arguments>):
<setup>
try:
yield <value>
finally:
<cleanup>
Should I use the 'try', and 'finally' as in the 2nd example, or should I use the first example? Does it matter?
More information about the Python-list
mailing list