<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, May 25, 2016 at 6:56 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What is your evidence for this claim? So far I've only seen one real-<br>
world use-case for this, and that single use-case would be well served<br>
by a simpler syntax:<br>
<span class=""><br>
a, b, c = **mapping<br>
<br>
</span>which just requires that a, b, c etc are legal names (not general<br>
identifiers). The dict is then unpacked:<br>
<br>
a = mapping['a']<br></blockquote><div><br></div><div>I can see how this spelling might be intuitive at first brush.  But the more I think about it, the more I recoil against the violation of a relatively uniform semantic principle in Python.</div><div><br></div><div>In no other case in Python, does the RHS of an assignment "probe into" the LHS to figure out how to determine its value.  Moreover, the idea that variable names are not just bindings, but also pseudo-literals, or maybe something akin to a Lisp 'symbol', feels enormously unpythonic to me.</div><div><br></div><div>Moreover, given that comprehensions are already available, and can express every variation we might want simply, I see no point of having this mild syntax sugar.  This includes binding in the usual style to arbitrary names, but also all the expected mechanisms of derived values and conditionals.  You can write:</div><div><br></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div>a, b, c = (mapping[x] for x in ['a','b','c'])</div></div></div></blockquote><div><br></div>But equally you can write a natural extension like:<div><br></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>x, y, z = (2*mapping[x] for x in get_keys() if x.isupper())</div></blockquote><div><br></div>Special casing the very simplest thing to save a minimal number of characters does not seem worthwhile.<div class="gmail_extra"><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</div></div></div>