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

Anders Hovmöller boxed at killingar.net
Tue Jun 25 12:19:46 CEST 2013


> Just a side idea, maybe what you want is not new syntax but a linter?
> Knock together a script that runs through your code and tells you
> about any oddities it finds, thus guaranteeing that your stuff does
> indeed match up. As an added bonus, you could plug that into your
> source control system so you get an alert before you can commit - not
> sure how you do that in Mercurial but I'm sure you can (I've only ever
> done it with git). Makes it really easy to catch problems.
>

I've thought about that but rejected it because then I'd have to change all
these functions to be keyword arguments. In an example I just scrolled to
randomly this changes a function call from 368 characters to 627! I believe
there are several worse examples :(

With my suggestion at least that function call would only go up to 595
without changing local variable names. If I also add the feature to my
suggestion that "foo(bar=something.bar)" == "foo(=something.bar)" (which is
pretty horrible!), I can get it down to 500 and still use keyword
arguments. And there'a few superflous Nones that I can get rid of if I use
keyword arguments, but only 5, which in this case doesn't change much.

Writing these numbers gives me the feeling that it's indeed this code base
that is pathological :P

If you know of an automated tool to convert functions from positional
arguments to keyword arguments that'd be a fun experiment to run :P
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130625/bfa17033/attachment.html>


More information about the Python-ideas mailing list