[Python-ideas] Re: Ampersand operator for strings

2023-03-06 Thread Stephen J. Turnbull
Rob Cliffe writes: > Perhaps where you're not laying out a table, I'm an economist, laying out tables is what I do. :-) Getting serious: > but constructing a human-readable string?  So >     s1 + ' ' + s2 + ' ' + s3 > or >     ' '.join((s1, s3, s3)) > would become >     s1 & s2 & s3

[Python-ideas] Re: Ampersand operator for strings

2023-03-06 Thread Rob Cliffe via Python-ideas
On 06/03/2023 15:49, Stephen J. Turnbull wrote: Steven D'Aprano writes: > I like the look of the & operator for concatenation, so I want to like > this proposal. But I think I will need to see real world code to > understand when it would be useful. I have to second that motion. Pretty

[Python-ideas] Re: Ampersand operator for strings

2023-03-06 Thread Stephen J. Turnbull
Steven D'Aprano writes: > I like the look of the & operator for concatenation, so I want to like > this proposal. But I think I will need to see real world code to > understand when it would be useful. I have to second that motion. Pretty much any time I'm constructing lines containing varia

[Python-ideas] Re: Ampersand operator for strings

2023-03-06 Thread Joao S. O. Bueno
On Mon, Mar 6, 2023 at 7:37 AM Steven D'Aprano wrote: > (...) > I like the look of the & operator for concatenation, so I want to like > this proposal. But I think I will need to see real world code to > understand when it would be useful. > I'd say we paint the shed blue. I mean - maybe "|" is

[Python-ideas] Re: Ampersand operator for strings

2023-03-06 Thread Joao S. O. Bueno
On Mon, Mar 6, 2023 at 12:51 AM David Mertz, Ph.D. wrote: > Is it really that much longer to write `f"{s1} {s2}"` when you want that? > As for being that much longer: yes it is. The more important factor is, I think, the increase in complexity + readabiity for default strings is worth it in thi

[Python-ideas] Re: Ampersand operator for strings

2023-03-06 Thread Marc-Andre Lemburg
On 06.03.2023 11:33, Steven D'Aprano wrote: On Mon, Mar 06, 2023 at 10:33:26AM +0100, Marc-Andre Lemburg wrote: def join_words(list_of_words) return ' '.join([x.strip() for x in list_of_words]) That's not Rob's suggestion either. I know, but as I mentioned, I use the above often, where

[Python-ideas] Re: Ampersand operator for strings

2023-03-06 Thread Steven D'Aprano
On Mon, Mar 06, 2023 at 10:33:26AM +0100, Marc-Andre Lemburg wrote: > def join_words(list_of_words) > return ' '.join([x.strip() for x in list_of_words]) That's not Rob's suggestion either. Rob's suggestion is an operator which concats two substrings with exactly one space between them, wit

[Python-ideas] Re: Ampersand operator for strings

2023-03-06 Thread Marc-Andre Lemburg
On 02.03.2023 18:27, Rob Cliffe via Python-ideas wrote: Tl;dr: Join strings together with exactly one space between non-blank text where they join. I propose a meaning for     s1 & s2 where s1 and s2 are strings. Namely, that it should be equivalent to     s1.rstrip() + (' ' if (s1.strip() an