<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 25.05.2016 15:11, Michael Selik
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAGgTfkMu=FzEzoNh2VGog35Y-x-5_MFZQHdYbmJVO9xcHRB1sQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Clojure also supports mapping destructuring. Let's
        add that to Python!</div>
    </blockquote>
    <br>
    +1 for the general idea.<br>
    <br>
    Let's keep Python simple by providing flexible tools like the one
    you proposed instead of a monolithic switch-case. :)<br>
    <br>
    <blockquote
cite="mid:CAGgTfkMu=FzEzoNh2VGog35Y-x-5_MFZQHdYbmJVO9xcHRB1sQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <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>
    </blockquote>
    <br>
    Nice! I like the error message.<br>
    <br>
    I could imagine how this can be generalized to attribute access BUT
    I think its easier to discuss dict unpacking to the end first.<br>
    <br>
    <blockquote
cite="mid:CAGgTfkMu=FzEzoNh2VGog35Y-x-5_MFZQHdYbmJVO9xcHRB1sQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div><span style="line-height:1.5">This will be approximately as
            helpful as iterable unpacking was before PEP 3132 (</span><a
            moz-do-not-send="true"
            href="https://www.python.org/dev/peps/pep-3132/"><a class="moz-txt-link-freetext" href="https://www.python.org/dev/peps/pep-3132/">https://www.python.org/dev/peps/pep-3132/</a></a>).</div>
      </div>
    </blockquote>
    <br>
    I'd add that all benefits for iterable unpacking apply as well. So,
    what's true for iterable unpacking is true for dict unpacking, too.<br>
    <br>
    <blockquote
cite="mid:CAGgTfkMu=FzEzoNh2VGog35Y-x-5_MFZQHdYbmJVO9xcHRB1sQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <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>
    </blockquote>
    <br>
    That's basically suppressing the the ValueError above with the same
    justification as for PEP 3132.<br>
    <br>
    I for one find this one of the shortest proposals compared to other
    recent proposals I have seen.  :)<br>
    <br>
    Best,<br>
    Sven<br>
  </body>
</html>