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

Phillip J. Eby pje at telecommunity.com
Mon Apr 24 22:40:21 CEST 2006


At 01:19 PM 4/24/2006 -0700, Aahz wrote:
>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?

I read "EXPRESSION returns a value" as simply meaning that "value = 
EXPRESSION", i.e. that the result of computing EXPRESSION *is* the 
value.  That's what it usually means when we talk about expressions 
returning a value -- that computing the expression produces a value.

I still don't see a third thing here.  "EXPRESSION returns a value" (Thing 
1).  That value is "used to create a context" (by calling 
__context__).  This context (Thing 2) "is used to execute a block" (by 
calling __enter__ and __exit__).

I don't get how you can have a difference between "EXPRESSION" and "value 
it returns" unless you're bringing functions into play.  In everything else 
in Python, an expression *is* the value it returns.  How could it be otherwise?

Maybe you meant to write an explanation that included three objects, but 
what you wrote is actually a precise and accurate description of how things 
works.  The value produced by EXPRESSION is used to create a context, and 
the context is used to execute the block.  I don't know how you could 
explain it any more simply than that -- certainly not by adding a 
mysterious third gunman on the grassy knoll.  :)



More information about the Python-Dev mailing list