[Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

Nick Coghlan ncoghlan at gmail.com
Fri Jul 15 13:19:53 CEST 2005


M.-A. Lemburg wrote:
> If you then start using terms in the documentation that cause
> wrong associations, you make life harder for new programmers.

I agree that every new construct and protocol makes life that much harder for 
anyone learning Python, but the bit I'm having trouble grasping is why you 
think associating 'with' statements with the term 'context' is *wrong*.

The point of using that term in the documentation was to give people something 
to grab hold of that defines what the protocol is *for*, rather than dropping 
something completely abstract like "the 'with' protocol" on them.

What does a 'with object' do? Nothing obvious, and this poses a major problem 
when trying to write the associated documentation. For instance, what's the 
justification for the use of __enter__ and __exit__ as the method names?

OTOH, what does a 'context manager' do? It sets up and tears down a particular 
context as a section of code is entered and exited. Simple, succint, accurate, 
and provides a rationale for the method names used in the protocol.

There's clearly something that bothers you about this though, and I'd like to 
understand what it is. Does the term 'context' carry additional, more 
specific, connotations for you that I'm simply not taking into account?

Regards,
Nick.

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


More information about the Python-Dev mailing list