Here's an interesting idea regarding yield **x:

Right now a function containing any yield returns a generator.  Therefore, it works like a generator expression, which is the lazy version of a list display.  lists can only contain elements x and unpackings *x.  Therefore, it would make sense to only have "yield x" and "yield *xs" (currently spelled "yield from xs")

If one day, there was a motivation to provide a lazy version of a dict display, then such a function would probably have "yield key: value" or "yield **d".   Such a lazy dictionary is the map stage of the famous mapreduce algorithm.  It might not make sense in single processor python, but it might in distributed Python.

Best,

Neil

On Fri, Oct 14, 2016 at 3:34 AM Sjoerd Job Postmus <sjoerdjob@sjoerdjob.com> wrote:
On Fri, Oct 14, 2016 at 07:06:12PM +1300, Greg Ewing wrote:
> Sjoerd Job Postmus wrote:
> >I think the suggested spelling (`*`) is the confusing part. If it were
> >to be spelled `from ` instead, it would be less confusing.
>
> Are you suggesting this spelling just for generator
> comprehensions, or for list comprehensions as well?
> What about dict comprehensions?

For both generator, list and set comprehensions it makes sense, I think.
For dict comprehensions: not so much. That in itself is already sign
enough that probably the */** spelling would make more sense, while also
allowing the `yield *foo` alternative to `yield from foo`. But what
would be the meaning of `yield **foo`? Would that be `yield
*foo.items()`? I have no idea.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

--

---
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ideas/ROYNN7a5VAc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ideas+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.