[Python-ideas] Python 4: Concatenation

Soni L. fakedme+py at gmail.com
Fri Jun 30 10:39:48 EDT 2017



On 2017-06-30 09:43 AM, Steven D'Aprano wrote:
> On Fri, Jun 30, 2017 at 12:51:26PM +0100, Jamie Willis wrote:
>
>> Just as an aside, if a concatenation operator *was* included, a suitable
>> operator would be "++",
> As mentioned earlier in this thread, that is not possible in Python as
> syntactically `x ++ y` would be parsed as `x + (+y)` (the plus binary
> operator followed by the plus unary operator).
>
>> this is the concatenation operator in languages
>> like Haskell (for strings) and the majority of Scala cases. Alternatively
>> "<>" is an alternative, being the monoidal append operator in Haskell,
>> which retains a certain similarly.
> "<>" is familiar to many people as "not equal" in various programming
> languages, including older versions of Python. I'm not entirely sure
> what connection "<>" has to append, it seems pretty arbitrary to me,
> although in fairness nearly all operators are arbitrary symbols if you
> go back far enough.
>
>

|| is the mathematical notation for concatenation. Which, just so 
happens to be available in Python, even if it might be confused with 
short-circuiting `or`.


More information about the Python-ideas mailing list