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

Nick Coghlan ncoghlan at gmail.com
Mon May 1 14:32:06 CEST 2006


Fredrik Lundh wrote:
> a distinct term for "whatever the __enter__ method returns" (i.e.
> the thing assigned to the target list) would still be nice.

I've called that the "context entry value" in a few places (I don't think any 
of them were in the actual documentation though).
A sample modification to the reference page:
------------------------------
Here's a more detailed description:
 1. The context expression is evaluated, to obtain a context guard.
 2. The guard object's __enter__ method is invoked to obtain the context
 entry value.
 3. If a target list was included in the with statement, the context entry
 value is assigned to it.
 4. The suite is executed.
 5. The guard object's __exit__ method is invoked. If an exception caused
 the suite to be exited, its type, value, and traceback are passed as
 arguments to __exit__. Otherwise, three None arguments are supplied.
------------------------------
Cheers,
Nick.
-- 
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
 http://www.boredomandlaziness.org


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /