Message132090
Agreed with nick's idea, the implicitly recreation of the context managers would confuse users.
How about removing the "generator must yield exactly one value" restriction of @contextlib.contextmanage? Then if I want a generator to be used as a common context manager, I can make it yield exactly one value, else further if I want the resulting context manager can be used as a decorator, (reusable), I can put the generator code in a "while True" loop and add a "yield" at the end of loop body, like this:
@contextmanager
def func():
while True:
print('begin func')
yield
print('end func')
yield
:) |
|
Date |
User |
Action |
Args |
2011-03-25 14:17:03 | ysj.ray | set | recipients:
+ ysj.ray, ncoghlan, pitrou, michael.foord |
2011-03-25 14:17:03 | ysj.ray | set | messageid: <1301062623.08.0.877059956298.issue11647@psf.upfronthosting.co.za> |
2011-03-25 14:17:02 | ysj.ray | link | issue11647 messages |
2011-03-25 14:17:02 | ysj.ray | create | |
|