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

Paul Moore p.f.moore at gmail.com
Mon Apr 24 00:47:28 CEST 2006


> Aside from the What's New document, this has now been done. My modifications
> consisted of terminology changes in the contextlib docs and the language
> reference to match the 2.5a1 implementation, a Context Types addition to the
> library reference similar to that for Iterator Types, and a very brief
> addition to Chapter 8 of the tutorial. It should all filter through the
> pipeline and appear on python.org in the next few hours.

OK, after a *very* quick look, here's my initial impression. I'll do a
better look tomorrow.

- It seems self-consistent, now, at least.

- Surely the __context__ method should be called __contextmgr__ now
that it's producing a context manager? (Same naming issue, just the
other side of it...)

- The addition of the section on context types is useful, no matter
what the final naming is.

- I don't see why context managers (the ones with __enter__ and
__exit__) need a __context__ method as well. To allow both contexts
and context managers to be used with the "with" statement, it says.
But there's no explanation of why that's a good thing. I see the
parallel with "all iterators are iterables", but in the absence of the
analog of the iter() builtin, I'm not so sure how I'd ever end up with
a raw context manager (short of calling __context__ manually) to use
in a with statement. So for my money, the iterator/context analogy
breaks down here, precisely because raw iterators are far more common
than raw context managers. (Oh, and by the way, writing this sentence
reinforced the reason I perfer the old terminology - "context manager"
feels like the name of something more concrete than "context", and yet
under your new terminology, the "context" is more concrete than the
"context manager"!)

OK, that's all I'll say for now. As I say, I'll do a better
read-through tomorrow.

Paul.


More information about the Python-Dev mailing list