On 4/24/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Paul Moore wrote: > > I've proposed splitting it into > > two, but that seems not to suit you (you've never responded to it > > specifically, so I may be misreading your silence here). > > Wanting to have two names for the same function tells me there's a problem > with the terminology, not that we should actually have two names for the same > function :)
My apologies. On rereading the code, I realised that I'd got muddled by the decorator implementation. [For anyone reading along, if you think I'm confused over contexts, watch me try to explain decorators!!!!] So my explanation was unclear. I'll try again. In the documentation of contextmanager, consider the examples: @contextmanager def tag(name): ... class Tag: ... @contextmanager def __context__(self): ... Now, tag should be a function which returns a context manager (a1 definition - object with a __context__ method) ("with" statement, item 1 of the definition). On the other hand, Tag.__context__ is a context manager's __context__ method, which according to item 2 of the definition of the "with" statement, should be a function which returns a context object (a1 definition - object with __enter__ and __exit__ methods). *These are two different types of function*. Just because contextmanager is implemented in such a way that decorated functions return objects with all 3 methods, doesn't make the functions conceptually the same. Does this help you to understand my concern? If not, I give up. (With one proviso - you insist that objects with __enter__ and __exit__ must supply __context__. I don't see why that's necessary, but I'll put that in another post). Paul. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com