Having an operand blank or all whitespace is not a common use case for
join, nor would it be for my proposed '&' operator. I wanted to present
a clear definition, and however I chose it, those corner cases would be
non-obvious.
That said, I have now withdrawn this proposal due to objections by
It's not that tricky to have the lstrip/rstrip behaviour with a join:
def space_join(*args):
first, *middle, last = args
return ' '.join((first.rstrip(), *(s.strip() for s in middle),
last.lstrip()))
What is harder is to be sure that this would be the expected behaviour when
using a `&`
On 07/03/2023 09:54, Valentin Berlier wrote:
I'm -1 on this. You can easily make a helper that achieves the desired syntax. Presenting
"human readable data" isn't just about collapsing spaces, and having your own
helper means that you can adjust the formatting to your specific use case if
Bikeshedding:
1) I forgot to mention whether the '&' operator should apply to byte
strings as well as to strings.
I propose that it should (some supporting examples below).
2) Joao suggested spelling the operator '|'.
But for me: '|' suggests "or" while '&' suggests "and" and is a
more
You make a very powerful point, Bruce. Much more so IMO than anyone
else has so far.
Unless anyone else can find a convincing rebuttal, I withdraw my proposal.
Best wishes
Rob Cliffe
On 07/03/2023 21:49, Bruce Leban wrote:
On Sun, Mar 5, 2023 at 7:39 PM Rob Cliffe via Python-ideas
wrote:
On Sun, Mar 5, 2023 at 7:39 PM Rob Cliffe via Python-ideas <
python-ideas@python.org> wrote:
> Tl;dr: Join strings together with exactly one space between non-blank
>
This idea is inappropriate for inclusion in the language. There are too
many subtle details in how this should work as noted by
I agree. This behavior is too specialized to be implemented as an
operator. + is IME so infrequently used on python strings that we should
take caution when proposing new binary string operators. Two strings to
concat, maybe; three, possibly; four or more, and I reach for join() or
f-strings or
On 07/03/2023 07:26, Stephen J. Turnbull wrote:
Rob Cliffe writes:
> Perhaps where you're not laying out a table,
I'm an economist
Oh goody! *Please* tell me what our Government needs to do to grow the
UK economy and curb inflation. I'll inform my MP immediately.
Seriously though ...
I'm -1 on this. You can easily make a helper that achieves the desired syntax.
Presenting "human readable data" isn't just about collapsing spaces, and having
your own helper means that you can adjust the formatting to your specific use
case if needed (for example with a different separator).
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
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
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
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 "|"
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
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,
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,
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()
On Sun, Mar 05, 2023 at 10:49:12PM -0500, David Mertz, Ph.D. wrote:
> Is it really that much longer to write `f"{s1} {s2}"` when you want that?
That's not the same as Rob's proposal.
--
Steve
___
Python-ideas mailing list -- python-ideas@python.org
Is it really that much longer to write `f"{s1} {s2}"` when you want that?
Maybe a couple characters more total, but once you are in an f-string, you
can also do a zillion other things at the same time.
On Sun, Mar 5, 2023 at 10:42 PM Rob Cliffe via Python-ideas <
python-ideas@python.org> wrote:
19 matches
Mail list logo