[Python-ideas] Fwd: Fwd: Fwd: unpacking generalisations for list comprehension

אלעזר elazarg at gmail.com
Mon Oct 17 14:53:21 EDT 2016


On Mon, Oct 17, 2016 at 9:49 PM David Mertz <mertz at gnosis.cx> wrote:
...

> Moreover, this "magical flatten" operator will crash in bad ways that a
> regular flatten() will not.  I.e. this is fine (if strange):
>
> >>> three_inf = (count(), count(), count())
> >>> comp = (x for x in flatten(three_inf))
> >>> next(comp)
> 0
> >>> next(comp)
> 1
>
> It's hard to see how that won't blow up under the new syntax (i.e.
> generally for all infinite sequences).
>
> The proposed semantics replace the asterisk with a "yield from" in a
generator, so it should work just fine.

Elazar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161017/35b6a711/attachment-0001.html>


More information about the Python-ideas mailing list