<div dir="ltr">Well no, because:<div><br></div><div style><div>foo(**dict(a=a, b=b, c=c))</div><div>foo(**{'a':a, 'b':b, 'c':c})</div><div>foo(a=a, b=b, c=c)</div><div><br></div><div style>are all the same thing. So the short forms should match in the same way:</div>
<div style><br></div><div style><div>foo(**dict(=a, =b, =c))</div><div>foo(**{:a, :b, :c})</div><div>foo(=a, =b, =c)</div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jun 22, 2013 at 8:26 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 22/06/2013 11:27, Anders Hovmöller wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Keyword arguments are great for increasing readability and making code<br>
more robust but in my opinion they are underused compared to the gains<br>
they can provide. You often end up with code like:<br>
<br>
foo(bar=bar, baz=baz, foobaz=foobaz)<br>
<br>
which is less readable than the ordered argument version when the names<br>
of the variables and the keywords match. ( Here's another guy pointing<br>
out the same thing:<br>
<a href="http://stackoverflow.com/questions/7041752/any-reason-not-to-always-use-keyword-arguments#comment8553765_7041986" target="_blank">http://stackoverflow.com/<u></u>questions/7041752/any-reason-<u></u>not-to-always-use-keyword-<u></u>arguments#comment8553765_<u></u>7041986</a>)<br>
<br>
I have a suggestion that I believe can enable more usage of keyword<br>
arguments while still retaining almost all the brevity of ordered<br>
arguments: if the variable name to the right of the equal sign equals<br>
the keyword argument ("foo=foo") make it optional to just specify the<br>
name once ("=foo"). For completeness I suggest also make the same change<br>
for dictionaries: {'foo': foo} -> {:foo}. This change would turn the<br>
following code:<br>
<br>
a = 1<br>
b = 2<br>
c = 3<br>
d = {'a':a, 'b':b, 'c':c}<br>
foo(a=a, b=b, c=c)<br>
<br>
into:<br>
<br>
a = 1<br>
b = 2<br>
c = 3<br>
d = {:a, :b, :c}<br>
</blockquote>
<br></div></div>
Shouldn't that mean:<div class="im"><br>
<br>
d = {a:a, b:b, c:c}<br>
<br>
</div><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
foo(=a, =b, =c)<br>
<br>
<br>
This should be compatible with existing code bases since the new forms<br>
are syntax errors in current python.<br>
<br>
What do you think?<br>
<br>
</blockquote></div>
I'm not convinced.<br>
<br>
______________________________<u></u>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-ideas</a><br>
</blockquote></div><br></div>