[issue11647] function decorated with a context manager can only be invoked once

Ray.Allen report at bugs.python.org
Fri Mar 25 15:50:13 CET 2011


Ray.Allen <ysj.ray at gmail.com> added the comment:

> > Agreed with nick's idea, the implicitly recreation of the context
> > managers would confuse users.

> Uh, why would it? That's exactly what I expect the decorator to do, and
> I was astonished to discover that it *doesn't*.


Because there is no *OBVIOUS* code or sign which can illustrate that context manager changes from a one-shot to a reusable. When using in "with" statement, it's a one-shot, while using as a decorator, it becomes a reusable. I think the way using it doesn't provide enough reason for its behavior change. Is there somebody who may expected that the GeneratorContextManager IS a one-shot?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11647>
_______________________________________


More information about the Python-bugs-list mailing list