[Python-ideas] A couple of with statement ideas

Cameron Simpson cs at zip.com.au
Fri Feb 25 22:49:25 CET 2011


On 25Feb2011 13:14, Bruce Leban <bruce at leapyear.org> wrote:
| On Fri, Feb 25, 2011 at 12:55 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
|  wrote:
| > From: Nick Coghlan
| > > It's at least a much larger set than it was back when AMK noticed the
| > > deep terminology confusion in the first version of the with statement
| > > and context management documentation (which was when Guido applied the
| > > Zen and dropped the __context__ method from the protocol).
| >
| > I'm in favour of the idea, but the terminology problem still
| > needs to be solved. I think it's important that the name of the
| > object implementing this protocol not have the word "context" in
| > it *anywhere*.
| >
| > I like __with__ as the special method name, as it very obviously
| > suggests a tight connection with the with-statement.
| 
| If the field returns a context manager, then the natural name to my mind
| would be __context_manager__.

It's very long... but accurate.

| What I don't like about __with__ is that it's not a noun and doesn't tell me
| what value the attribute has or what I would do with it.

"enter" and "exit" aren't nouns either. I guess they are events though,
whereas __with__ is supposed to return something. Grammar aside I like
__with__, personally, since __context__ seems to be out.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

BROCCOLI!! THE ONLY VEGETABLE THAT SOUNDS LIKE AN ADVERB!!
        - ken at aiai.ed.ac.uk (Ken Johnson)



More information about the Python-ideas mailing list