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

Nick Coghlan ncoghlan at gmail.com
Tue Apr 25 05:45:17 CEST 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.  :)

"the block executes with the lock held"
"the block executes with the file open, and closes it when finished
"the block executes with stdout redirected to the file f"
"the block executes with opening and close HTML tags written to stdout before 
and after the code is executed"
"the block executes with the active decimal context set to a copy of the 
supplied context object"

Believe me, it may not be representable as a Python object, but the "runtime 
context" created by a with statement is very real, and its what users actually 
give a damn about. The concrete objects (whatever we call them) are 
implementation details. And this is why I now believe using "context object" 
for *either* of the concrete objects would be a mistake.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list