[Python-ideas] Revised**12 PEP on Yield-From
Jacob Holm
jh at improva.dk
Sun Apr 19 18:26:35 CEST 2009
Scott David Daniels wrote:
> Now that we passed the magic three or four threshold, is
> it not easier to read if we pick some better names?
>
> _iter = iter(EXPR)
> _call, _arg = next, _iter
^^^^^ should be (_iter,)
> while 1:
> try:
> _out = _call(_arg)
^^^^ should be *_arg
> except StopIteration as _except:
> _result = _except.value
> break
> try:
> _in = yield _out
> except GeneratorExit as _except:
> try:
> _close = _iter.close
> except AttributeError:
> pass
> else:
> _close()
> raise _except
> except BaseException as _except:
> _a = sys.exc_info()
^^ should be _arg, forcing the other changes.
> try:
> _call = _iter.throw
> except AttributeError:
> raise _except
> else:
> if _in is None:
> _call, _arg = next, _iter
^^^^^ should be (_iter,)
> else:
> _call, _arg = _iter.send, _in
^^^ should be (_in,)
> RESULT = _result
As noted inline, you missed one of the _a's and so falsely assumed there
would always only be one argument to _call. In the case of throw there
is 3.
I don't really care what the variables are called. That bikeshed
discussion is not one I want to participate in. Your names are as good
as any I guess.
Anyway, this is moot unless Greg agrees that this style of expansion is
a good idea in the first place.
Not-bikeshedding-ly yours
- Jacob
More information about the Python-ideas
mailing list