A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-May/064681.html below:

[Python-Dev] More on contextlib - adding back a contextmanager decorator

[Python-Dev] More on contextlib - adding back a contextmanager decorator [Python-Dev] More on contextlib - adding back a contextmanager decoratorGreg Ewing greg.ewing at canterbury.ac.nz
Mon May 1 14:02:45 CEST 2006
Nick Coghlan wrote:
> the context expression in the with 
> statement produces a context manager with __enter__ and __exit__ methods 
> which set up and tear down a managed context for the body of the with 
> statement. This is very similar to your later suggestion of context 
> guard and guarded context.

Currently I think I still prefer the term "guard",
since it does a better job of conjuring up the same
sort of idea as a try-finally.

There's also one other issue, what to call the
decorator. I don't like @contextfactory, because it
sounds like something that produces contexts,
yet we have no such object.

With only one object, it should probably be named
after that object, i.e. @contextmanager or
@contextguard. That's if we think it's really
worth making it easy to abuse a generator in this
way -- which I'm not convinced about. It's not
as if people are going to be implementing context
managers/guards every day.

--
Greg
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4