[Python-Dev] PEP 343 update (with statement context terminology) (original) (raw)
Paul Moore p.f.moore at gmail.com
Mon Apr 24 22:29:41 CEST 2006
- Previous message: [Python-Dev] PEP 343 update (with statement context terminology)
- Next message: [Python-Dev] PEP 343 update (with statement context terminology)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 4/24/06, Nick Coghlan <ncoghlan at gmail.com> 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.
- Previous message: [Python-Dev] PEP 343 update (with statement context terminology)
- Next message: [Python-Dev] PEP 343 update (with statement context terminology)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]