On Apr 24, 2006, at 03:49, Nick Coghlan wrote: > Just van Rossum wrote: >> Baptiste Carvello wrote: >> >>> Terry Reedy a écrit : >>>> So I propose that the context maker be called just that: 'context >>>> maker'. That should pretty clearly not be the context that manages >>>> the block execution. >>>> >>> +1 for context maker. In fact, after reading the begining of the >>> thread, I came up with the very same idea. >> >> Or maybe "context factory"? Yes its a factory. That is traditionally that you call a function that makes objects isn't it? > That would be fine if we used __call__ to retrieve the context > manager - but > "factory" is too tightly bound to "factory function" in my mind. __call__ may or may not implement a factory, that is up to my design to decide. __context__ is always a factory because that is the interface that "with" mandates. factory function is one way to implement a factory so yes its tightly bound, but that not a reason to reject factory. From what I've read on this list this is all there is to it: with EXPR: block with needs a context. If the EXPR object has a __context__ method it is a factory that will make a suitable context for the EXPR object otherwise EXPR is the context. that context must have __enter__ and __exit__ methods to operate the with protocol. I haven't learn about decorators so I've no comment on why you need them as well as the special method names. But the docs should tell me why. Barry
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4