[Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343
Michael Hudson
mwh at python.net
Fri Jul 15 11:37:10 CEST 2005
"M.-A. Lemburg" <mal at egenix.com> writes:
> 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.
I, as a concrete example, want to be able to write:
with output_to_file(f):
print stuff
function_that_prints_stuff()
and have the printed things end up in the file-like object f (in a
single-threaded program, foom :)
This is only a resource by a tortured defintion.
> 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".
Of course, but there's no single term to describe all these simple
things, and we need a single term to describe the objects designed to
be used in the with statement for documentation purposes. Consensus
on python-dev has settled on 'context manager', but personally I don't
much care what it is so long as it isn't actively misleading (which I
contend applies to 'resource manager'), it's just something people can
look up in the index.
> Let's keep things simple and Python nice.
Are you arguing against PEP 343 as a whole, here?
Cheers,
mwh
--
CLiki pages can be edited by anybody at any time. Imagine the most
fearsomely comprehensive legal disclaimer you have ever seen, and
double it -- http://ww.telent.net/cliki/index
More information about the Python-Dev
mailing list