Crazy what-if idea for function/method calling syntax

ΤΖΩΤΖΙΟΥ tzotzioy at
Mon Jul 18 00:54:17 CEST 2011

Jumping in:

What if a construct

   xx(*args1, **kwargs1)yy(*args2, **kwargs2)

was interpreted as

  xxyy(*(args1+args2), **(kwargs1+kwargs2))

(Note: with **(kwargs1+kwargs2) I mean “put keyword arguments in the
order given”, since dicts can't be added)

This construct is currently a syntax error. The intent of this idea is
to help improve legibility.

  def place_at(item, x, y): blah blah
could be called as
  place(item)_at(x, y)

I believe it makes code more readable; it's also a more terse
alternate to a call like:
  place_at(item=item, x=x, y=y)

Another example:

I can think of some objections myself; the most important is whether
the current parser (with a complexity defined by the wishes of Guido,
which I faintly recall reading about a long time ago) can do that or
not. I also don't know if any other language exists supporting this

There is also a big window for misuse (i.e. break the function/method
name in illogical places), but I would classify this under “consenting
adults”. It might be suggested as good form that function names break
at underscores, like my examples.

I know it seems extreme. I only posted this idea here because I would
like some input about how feasible it can be and whether people like
it or not. Any input is welcome; however, I kindly request that
negative replies include counter-arguments (an abrupt “no” or “yuck!”
does not help others improve their knowledge of Python or Pythonic-
ness :).

Thanks in advance.

More information about the Python-list mailing list