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 ncoghlan
Recipients jackdied, michael.foord, ncoghlan, rhettinger
Date 2010-07-10.08:16:43
SpamBayes Score 2.1342808e-05
Marked as misclassified No
Message-id <1278749806.31.0.935627134747.issue9110@psf.upfronthosting.co.za>
In-reply-to
Content
One thing that Jack's confusion above does suggest to me is that we should mention in the *ContextDecorator* documentation that it is automatically applied to the context managers created when you use @contextmanager. A lot of people familiar with contextmanager are just going to read the docs for the new toy, so may miss the fact that we have added __call__ support to GeneratorContextManager.

As far as use cases go, this change is just syntactic sugar for any construct of the following form:

  def f():
    with cm():
      # Do stuff

ContextDecorator lets you instead write:

  @cm
  def f():
    # Do stuff

It makes it clear that the CM applies to the whole function, rather than just a piece of it (and saving an indentation level is nice, too).
History
Date User Action Args
2010-07-10 08:16:46ncoghlansetrecipients: + ncoghlan, rhettinger, jackdied, michael.foord
2010-07-10 08:16:46ncoghlansetmessageid: <1278749806.31.0.935627134747.issue9110@psf.upfronthosting.co.za>
2010-07-10 08:16:44ncoghlanlinkissue9110 messages
2010-07-10 08:16:44ncoghlancreate