[Python-ideas] Unpacking a dict

Sven R. Kunze srkunze at mail.de
Thu May 26 12:50:12 EDT 2016


On 26.05.2016 14:27, Koos Zevenhoven wrote:
> That said, here's a couple of suggestions:
>
>     **(a, b, c) = **mapping
>
>     **{a, b, c} = **mapping
>
> Although `a, b, c = **mapping` would still be more convenient.
>
> ​-- Koos

Do you see what you just did there?

**{a, b, c} = **mapping

That seems like a mathematical equation where the ** appear to be 
superfluous (besides I don't really like special characters ;-) ). So it 
yields:

{a, b, c} = mapping


However and additionally, here the LHS (and the LHS in your suggestion) 
reminds me of a set. That's not good I guess. I one now adds the keys 
back in we go back to

{'a': s1, 'b': s2, 'c': s3} = mapping


So far, all proposals which deviate from Michael's one are just 
"optimizations in terms of characters". The only one I would find not 
necessarily too restrictive were:


'a': s1, 'b': s2, 'c': s3 = mapping   # no braces :)


That looks quite good to me. What do you think?


Best,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160526/6373ebf6/attachment.html>


More information about the Python-ideas mailing list