[Python-ideas] Allow using ** twice

Andrew Barnert abarnert at yahoo.com
Thu Jun 6 19:29:43 CEST 2013


On Jun 6, 2013, at 8:43, Haoyi Li <haoyi.sg at gmail.com> wrote:

> > There should be one way to do it...
> 
> I'd agree except, well, there are two different things that people want to do here!

Actually, there's three:

1. Right values take precedence.
2. Left values take precedence.
3. Assert that there are no duplicate keys.

I think the first is what people would expect, and want, more often, because it's exactly what you get when you do the obvious thing today. It also means a+=b means a.update(b), just as it means a.extend(b) for sequences--and note that there is no method that adds the new keys from b while leaving existing ones alone or raising an exception.

But I also think that most of the time people won't care. If you write draw(x, y, **(image_keywords * window_keywords)), you've got two non overlapping sets of keys.

> So in the end you're gonna have to let people do both, somehow.

Or you can provide one obvious way to do the common case that people will use all the time, and explain how you do the less obvious cases when they occasionally come up.

Also, note that if we implement case 1, it's pretty obvious how to do case 2: just do b+a instead of a+b.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130606/927412fa/attachment.html>


More information about the Python-ideas mailing list