[Python-ideas] Python 4: Concatenation

Terry Reedy tjreedy at udel.edu
Fri Jun 30 16:59:49 EDT 2017


On 6/30/2017 9:24 AM, Oleg Broytman wrote:
> On Fri, Jun 30, 2017 at 03:10:08PM +0200, "Sven R. Kunze" <srkunze at mail.de> wrote:
>> '+' is the perfect concat operator. I love Python for this feature.
> 
>     +1 from me <bigwink>

and me.  I think extending it to chain iterators is an intriguing idea. 
It would not be the first time syntax was implemented with more than one 
special method.  When the boolean value of an object is needed, first 
.__bool__, then .__len__ are used.  Iter() first tries .__iter__, then 
.__getitem__.

When counts are expressed in their original unary notation, addition is 
concatention. If one thinks of a sequence as a unary representation of 
its length*, then concatenation is adddition.

*This is a version of the mathematical idea of cardinal number.

Whether intentionally or by accident, or perhaps, whether by analysis or 
intuition, I think Guido got this one right.

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list