[Python-Dev] PEP 343 update (with statement context terminology)

Aahz aahz at pythoncraft.com
Mon Apr 24 22:19:02 CEST 2006


On Mon, Apr 24, 2006, Phillip J. Eby wrote:
> At 12:49 PM 4/24/2006 -0700, Aahz wrote:
>>On Mon, Apr 24, 2006, Phillip J. Eby wrote:
>>> At 12:24 PM 4/24/2006 -0700, Aahz wrote:
>>>>On Mon, Apr 24, 2006, Phillip J. Eby wrote:
>>>>> At 04:48 AM 4/25/2006 +1000, Nick Coghlan wrote:
>>>>>>
>>>>>>Using two names to describe three different things isn't intuitive for
>>>>>>anybody.
>>>>>
>>>>> Um, what three things?  I only count two:
>>>>>
>>>>> 1. Objects with __context__
>>>>> 2. Objects with __enter__ and __exit__
>>>>>
>>>>> What's the third thing?
>>>>
>>>>The actual context that's used during the execution of BLOCK.  It does
>>>>not exist as a concrete object,
>>>
>>> Um, huh?  It's a thing but it's not an object?  I'm lost now.  I don't see
>>> why we should introduce a concept that has no concrete existence into
>>> something that's hard enough to explain when you stick to the objects that
>>> actually exist.  :)
>>
>>Let's go back to a pseudo-coded with statement:
>>
>>     with EXPRESSION [as NAME]:
>>         BLOCK
>>
>>What happens while BLOCK is being executed?  Again, here's what I said
>>originally:
>>
>>     EXPRESSION returns a value that the with statement uses to create a
>>     context (a special kind of namespace).  The context is used to
>>     execute the BLOCK.  The block might end normally, get terminated by
>>     a break or return, or raise an exception. No matter which of those
>>     things happens, the context contains code to clean up after the
>>     block.
>>
>>Do you have an alternate proposal for describing this that works well for
>>newbies?
> 
> No, I like your phrasing -- but it's quite concrete.  EXPRESSION returns a 
> value (object w/__context__) used to create a context (object w/__enter__ 
> and __exit__).
> 
> That's only two things.  There is no *third* thing here.

What is EXPRESSION, then?  Not the value it returns, but EXPRESSION
itself -- does it have a name?  What about the kinds of things we use
for EXPRESSION?
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Argue for your limitations, and sure enough they're yours."  --Richard Bach


More information about the Python-Dev mailing list