This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ysj.ray
Recipients michael.foord, ncoghlan, pitrou, ysj.ray
Date 2011-03-25.14:17:02
SpamBayes Score 6.321904e-05
Marked as misclassified No
Message-id <1301062623.08.0.877059956298.issue11647@psf.upfronthosting.co.za>
In-reply-to
Content
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

:)
History
Date User Action Args
2011-03-25 14:17:03ysj.raysetrecipients: + ysj.ray, ncoghlan, pitrou, michael.foord
2011-03-25 14:17:03ysj.raysetmessageid: <1301062623.08.0.877059956298.issue11647@psf.upfronthosting.co.za>
2011-03-25 14:17:02ysj.raylinkissue11647 messages
2011-03-25 14:17:02ysj.raycreate