
On Sat, Feb 26, 2011 at 8:46 AM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
From: Bruce Leban [mailto:bruce@leapyear.org]
Why do you think "it's important that the name ... not have the word "context" in it *anywhere*"?
Maybe it's not that important. I'm just trying to avoid any chance of lingering confusion.
The best I have at the moment is "objects with an implicit context manager", but that's still a huge improvement over where we were when PEP 343 was implemented. Back then, we weren't sure whether "context manager" referred to the objects with __context__ or the objects with __enter__/__exit__. Since Guido decided to drop the first option completely, the question is now solidly resolved in favour of the latter, so it opens up the possibility of adding back a __with__, __cm__, __context_manager__ or __manager__ method using a new term or phrase for the objects that implement it. The iterator/iterable precedent suggests manager->manageable as a possibility, but "manageable objects" isn't easy to write *or* to say. "Managed objects" could work, though (despite being slightly less technically correct). It sounds like there's enough interest in that idea that it's worth pursuing - it still needs someone to write/champion the PEP though. No comments on the PEP 377 variant though, which is a little disappointing. I see the fact that, depending on the details of cmA() and cmB() this code: @contextmanager def cmAB(): with cmA(), cmB(): yield with cmAB(): # Do stuff may throw RuntimeError, while the inline equivalent works just fine: with cmA(), cmB(): # Do stuff as a bit of a design flaw in the underlying structure of the context management protocol. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia