On 10/9/05, Anders J. Munch <andersjm at inbound.dk> wrote: > Nick Coghlan wrote: > >Anders J. Munch wrote: > > > >>Note that __with__ and __enter__ could be combined into one with no > >>loss of functionality: > >> > >> abc,VAR = (EXPR).__with__() > >> > > > >They can't be combined, because they're invoked on different objects. > > > > Sure they can. The combined method first does what __with__ would > have done to create abc, and then does whatever abc.__enter__ would > have done. Since the type of 'abc' is always known to the author of > __with__, this is trivial. I'm sure it can be done, but I find this ugly API design. While I'm not keen on complicating the API, the decimal context example has convinced me that it's necessary. The separation into __with__ which asks EXPR for a context manager and __enter__ / __exit__ which handle try/finally feels right. An API returning a tuple is asking for bugs. -- --Guido van Rossum (home page: http://www.python.org/~guido/)
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