Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343
![](https://secure.gravatar.com/avatar/3c2ce5e843cef58cf546b403c6233597.jpg?s=120&d=mm&r=g)
Nick writes sample documentation:
For example, the following context manager allows prompt closure of any resource with a 'close' method (e.g. a generator or file):
@context def closing(resource): try: yield resource finally: resource.close()
Reading this I get the feeling that perhaps the decorator should be named "context_manager" not "context": @context_manager def closing(resource): try: yield resource finally: resource.close() Does anyone else agree? Paul Moore writes:
I also like the fact that it offers a neat 1-word name for the generator decorator, "@context".
Well, ok... does anyone *else* agree? I too saw this and thought "neat! a simple one-word name!". But then I started worrying that it's not defining the *context*, but rather the *context manager*. While "context manager" is a term I could easily imagine associating only with 'with' statements, "context" is too general a term... even after Python supports 'with' statements I will continue to use "context" to mean lots of different things (eg: decimal.context). By the way, great job Nick... these docs read quite nicely. -- Michael Chermside
![](https://secure.gravatar.com/avatar/d995b462a98fea412efa79d17ba3787a.jpg?s=120&d=mm&r=g)
On 7/6/05, Michael Chermside <mcherm@mcherm.com> wrote:
Paul Moore writes:
I also like the fact that it offers a neat 1-word name for the generator decorator, "@context".
Well, ok... does anyone *else* agree? I too saw this and thought "neat! a simple one-word name!". But then I started worrying that it's not defining the *context*, but rather the *context manager*. While "context manager" is a term I could easily imagine associating only with 'with' statements, "context" is too general a term... even after Python supports 'with' statements I will continue to use "context" to mean lots of different things (eg: decimal.context).
Actually, you're starting to persuade me... Although I generally prefer decorator names which are single words. Along with the at-sign, underscores make the whole thing look a little too "punctuation-heavy" for me (and don't suggest camel case, please!). Paul.
![](https://secure.gravatar.com/avatar/8e002feb26c886a03871b602d7abd67b.jpg?s=120&d=mm&r=g)
Paul Moore wrote:
On 7/6/05, Michael Chermside <mcherm@mcherm.com> wrote:
Paul Moore writes:
I also like the fact that it offers a neat 1-word name for the generator decorator, "@context".
Well, ok... does anyone *else* agree? I too saw this and thought "neat! a simple one-word name!". But then I started worrying that it's not defining the *context*, but rather the *context manager*. While "context manager" is a term I could easily imagine associating only with 'with' statements, "context" is too general a term... even after Python supports 'with' statements I will continue to use "context" to mean lots of different things (eg: decimal.context).
Actually, you're starting to persuade me... Although I generally prefer decorator names which are single words. Along with the at-sign, underscores make the whole thing look a little too "punctuation-heavy" for me (and don't suggest camel case, please!).
Anything against @contextmanager in analogy to @staticmethod ? Reinhold -- Mail address is perfectly valid!
participants (3)
-
Michael Chermside
-
Paul Moore
-
Reinhold Birkenfeld