On Mon, Feb 03, 2003, holger krekel wrote: > > def __enter__(self): > "before suite start" > > def __except__(self, type, value, tb): > "swallow given exception, reraise if neccessary" > > def __leave__(self): > """upon suite finish (not called if __except__ > exists and an exception happened) > """ No, __leave__/__exit__ should always be called regardless of whether an exception hits. That's the whole point of this proposal, IMO. > One remark (mainly to Michael as he does that other > patch) about the hook-name __leave__ versus __exit__. > we may want to eventually allow 'yield' within the > thunk and then '__exit__' would be misleading. Here is > the use case: > > exec self.mylock: # would lock/unlock on entering/leaving > # the generator > ... > for whatever in something: > yield whatever > ... I'm thinking that this is *way* too complex. If you want something like that, code it like this: for whatever in something: exec self.mylock: new_whatever = process(whatever) yield new_whatever -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "Argue for your limitations, and sure enough they're yours." --Richard Bach
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