[Python-ideas] Short form for keyword arguments and dicts

Anders Hovmöller boxed at killingar.net
Sun Jun 23 13:17:07 CEST 2013


> He's clearly saying that you should use keywords when they add
> information, and not use them when they add nothing but noise. Your
> suggestion would make them add _less_ noise in one particular case where
> they add nothing but noise, but that's not a problem that needs to be
> solved, because Python already has a solution: don't use keywords in that
> case. Adding the extra = before each parameter just makes things less
> readable without giving any new information, so why should we add syntax to
> encourage it?
>

Because keyword arguments are less brittle. Consider the case you replied
to:

create_user(first_name=first_name, last_name=last_name,
contact_email=contact_email)

if you change it to:

create_user(first_name, last_name, contact_email)

it is more readable but it doesn't actually mean the same thing. The first
piece of code will break in a nice way when the keyword argument list is
changed in the definition of create_user. The second will probably fail,
but later and in some not so nice way like suddenly you have emails in your
database where you should've had addresses.

Objective-C is better in this case because it strongly enforces something
like keyword argument always. What I'm saying is that it'd be nice to be
able to write code that uses keyword arguments 100% of the time for all
function calls without making the readability worse.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130623/69016c9a/attachment.html>


More information about the Python-ideas mailing list