<div dir="ltr">Python's iterable unpacking is what Lispers might call a destructuring bind.<div><br></div><div>    py> iterable = 1, 2, 3, 4, 5</div><div>    py> a, b, *rest = iterable</div><div>    py> a, b, rest</div><div>    (1, 2, (3, 4, 5))</div><div><br></div><div>Clojure also supports mapping destructuring. Let's add that to Python!</div><div><br></div><div>    py> mapping = {"a": 1, "b": 2, "c": 3}</div><div>    py> {"a": x, "b": y, "c": z} = mapping</div><div>    py> x, y, z</div><div>    (1, 2, 3)</div><div>    py> <span style="line-height:1.5">{"a": x, "b": y} = mapping</span></div><div><span style="line-height:1.5">    Traceback:</span></div><div><span style="line-height:1.5">    ValueError: too many keys to unpack</span></div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">This will be approximately as helpful as iterable unpacking was before PEP 3132 (</span><a href="https://www.python.org/dev/peps/pep-3132/">https://www.python.org/dev/peps/pep-3132/</a>).</div><div><br></div><div>I hope to keep discussion in this thread focused on the most basic form of dict unpacking, but we could e<span style="line-height:1.5">xtended mapping unpacking similarly to how PEP 3132 extended iterable unpacking. Just brainstorming...</span></div><div><br></div><div>    py> <span style="line-height:1.5">mapping = {"a": 1, "b": 2, "c": 3}</span></div><div>    py> {"a": x, **rest} = mapping</div><div>    py> x, rest</div><div>    (1, {"b": 2, "c": 3})</div><div><br></div></div>