Guido van Rossum <[EMAIL PROTECTED]> writes: > [Michael Hudson, after much thinking aloud]
Yeah, sorry about that :) >> Oh, I guess the point is that with a decorated generator you can yield >> a value to be used as VAR, rather than just discarding the value as >> here. Hmm. > > Right. (I thought it was worth quoting this for the benefit of other > who went down the same trail but didn't quite make it to this > destination.) > >> If things were fiddled such that sys.exc_info() return non-Nones when >> a finally clause is being executed because of an exception, we don't >> really need this wart, do we? > > The problem is that sys.exc_info() almost always returns *something* > -- it's usually the last exception that was *ever* caught, except in > certain circumstances. Yeah, OK. I'll stop claiming to understand sys.exc_info() apart from the simple cases. > [Michael again] >> Compare and contrast: >> >> @template >> def redirected_stdout(out): >> save_stdout = sys.stdout >> sys.stdout = out >> >> yield None >> >> sys.stdout = save_stdout >> >> class redirected_stdout(object): >> >> def __init__(self, output): >> self.output = output >> >> def __enter__(self): >> self.save_stdout = sys.stdout >> sys.stdout = self.output >> >> def __exit__(self): >> sys.stdout = self.save_stdout >> >> The former is shorter and contains less (well, no) 'self.'s, but I >> think I find the latter somewhat clearer. > > Tastes differ. I think the generator wins; more so when there's more > state to remember. Certainly when there's more state to manage, yes. But both will be possible, so, *shrug*. It's not a big deal. > [Michael quoting Guido] >> > The added complexity is caused by the need to separate VAR from EXPR >> > so that a generator can be used. I personally like this separation; I >> > actually like that the "anonymous block controller" is logically >> > separate from the variable bound by the construct. >> >> Nevertheless, I think I actually like this argument! > > (Repeated for the benefit of others.) I guess this means PEP 310 can be retracted. Finally, from PEP 343 rev 1.7: exc = () # Or (None, None, None) ? The latter, please. Cheers, mwh -- . <- the point your article -> . |------------------------- a long way ------------------------| -- Christophe Rhodes, ucam.chat _______________________________________________ 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