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

Fred L. Drake, Jr. fdrake at acm.org
Thu Jul 7 02:10:10 CEST 2005


On Wednesday 06 July 2005 19:47, Raymond Hettinger wrote:
 > These names should be changed to __beginwith__ and __endwith__.  The
 > current names are too vague, not obviously paired with each other, not
 > obviously tied to the with-statement, and provide no hint about what
 > calls them.  Remember, the methods will appear among a slew of other
 > methods that have nothing to do with with-statements.  There will be no
 > surrounding contextual clue as to what these methods are for.

I don't really like this; what's to say there won't be some other client of 
the context protocol?  Should __iter__ have been __iterfor__?  (I don't think 
so.)

If we're worried about name clashes (and in __*__ space, no less!), then 
perhaps it makes sense to do something like __context__ (similar to 
__iter__), and use the __enter__ and __exit__ on the result of that method.

I'm not convinced there's a need to worry about clashes in the __*__ 
namespace, but I can see how it might be nice to provide an __context__ 
method similar to __iter__.  But I don't find it compelling, so... let's have 
__enter__ and __exit__, and be done.


  -Fred

-- 
Fred L. Drake, Jr.   <fdrake at acm.org>


More information about the Python-Dev mailing list