[Python-ideas] Implicit String Concatenation

Jason Orendorff jason.orendorff at gmail.com
Wed Apr 11 20:01:59 CEST 2007

On 4/11/07, Eoghan Murray <eoghan at qatano.com> wrote:
> This is exactly what I'm proposing.  You could spell it __juxta__  short for
> juxtaposition or __concat__, and overload it as usual :-)

And if __juxta__ is not defined, it should fall back first on
__call__, then __mul__, then __add__.  If it binds right-to-left, you
could write things like

  from math import *
  print (2 sin x + cos x)

We might as well make newlines an operator at the same time.  There's
precedent for this in Haskell, and good synergy--adding the STM monad
to Python would solve the GIL problem.  You could spell that operator
__bind__ or just __>>=__, take your pick.

And I think Guido already committed to ripping out the @decorator
syntax in Py3k in favor of comment overloading, via __rem__().

Just kidding, of course...

> Anyone with any positive reactions?

Eoghan, thanks for taking the time to write.  I don't think anyone
likes the idea, though.  It causes many grammatical problems:  should
a[0] parse as a.__getitem__(0) or a.__juxta__([0])?  What about
(foo)(bar)?  And while "sin x" would of course mean sin.__juxta__(x),
"sin -x" would parse as "sin - x", or sin.__sub__(x).

A few extra + signs are a small price to pay.


More information about the Python-ideas mailing list