[Python-ideas] Unpacking a dict
Sven R. Kunze
srkunze at mail.de
Wed May 25 11:07:39 EDT 2016
On 25.05.2016 15:11, Michael Selik wrote:
> I hope to keep discussion in this thread focused on the most basic
> form of dict unpacking, but we could extended mapping unpacking
> similarly to how PEP 3132 extended iterable unpacking. Just
> brainstorming...
Another idea (borrowed from Erlang):
>>> mapping = {"a": 1, "b": 2, "c": 3}
>>> {"a": x, "b": y, "c": 3} = mapping
>>> x,y
(1,2)
>>> mapping = {"a": 1, "b": 2, "c": 3}
>>> {"a": x, "b": y, "c": 2} = mapping
Traceback:
ValueError: key 'c' does not match to 2
Best,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160525/4247a8ad/attachment.html>
More information about the Python-ideas
mailing list