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

Phillip J. Eby pje at telecommunity.com
Mon Apr 24 21:58:16 CEST 2006


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.



More information about the Python-Dev mailing list