[Python-ideas] [Python-Dev] yield * (Re: Missing operator.call)
Leif Walsh
leif.walsh at gmail.com
Sun Feb 8 02:48:46 CET 2009
[+python-ideas -python-dev]
On Sat, Feb 7, 2009 at 8:50 PM, <glyph at divmod.com> wrote:
> has anyone considered the syntax 'yield from iterable'? i.e.
>
> def foo():
> yield 1
> yield 2
>
> def bar():
> yield from foo()
> yield from foo()
>
> list(bar()) -> [1, 2, 1, 2]
>
> I suggest this because (1) it's already what I say when I see the 'for'
> construct, i.e. "foo then *yield*s all results *from* bar", and (2) no new
> keywords are required.
I still don't understand why such a construct is necessary. Is
>>> for elt in iterable:
>>> yield elt
really all that bad? Maybe it's a little silly-looking, but at least
it's easy to understand and not _that_ hard to type....
--
Cheers,
Leif
More information about the Python-ideas
mailing list