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

M.-A. Lemburg mal at egenix.com
Thu Jul 14 21:15:28 CEST 2005


Nick Coghlan wrote:
> M.-A. Lemburg wrote:
> 
>>May I suggest that you use a different name than "context" for
>>this ?!
>>
>>The term "context" is way to broad for the application scopes
>>that you have in mind here (like e.g. managing a resource
>>in a multi-threaded application).
> 
> 
> It's actually the broadness of the term 'context' which is appealing - the 
> examples in the draft documentation on SF are:
> 
>    - resource management (synchronisation locks, generic 'closing')
>    - HTML tag matching
>    - Decimal arithmetic context
> 
> Any earlier version used 'suite managers' (partly to avoid confusing the hell 
> out of anyone ever exposed to Ruby's concept of blocks), but the 'context 
> management' term seems to more clearly describe what the protocol is for.

This is exactly what I'm getting at: I can see the potential
use for resource management (which is what started out the
whole idea IIRC), but fail to see why you'd want to use it
for anything more complicated than that.

Once you start talking about contexts (which usually refers
to a combination of environment, state and location) you
have to explain things like nesting, scopes, combination
of different contexts, their interaction with each other,
etc. etc.

Note that hiding things away in smart objects like what
you call "context managers" will not make programs easier
to understand, unless the specific task that such a "context
manager" is simple enough to grasp by just looking at its
definition in the with statement... but then you'd not call
it a "context manager".

BTW, the same argument applies to decorators. Programs don't
get easier to read or understand if you overload a function
with lots and lots of hidden magic...

@put_all_the_smart_stuff_here
def program(context):
    return "42"

Of course, you *could* do all these things and Python is
not preventing you from doing so, but will life get easier ?
I doubt it.

Let's keep things simple and Python nice.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jul 14 2005)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the Python-Dev mailing list