[Python-ideas] Re: join() could add separators at start or end

2023-03-08 Thread Bruce Leban
On Wed, Mar 8, 2023 at 4:34 PM Rob Cliffe via Python-ideas < python-ideas@python.org> wrote: > It seems to me that it would be useful to be able to make the str.join() > function put separators, not only between the items of its operand, but > also optionally at the beginning or end. > E.g. '|'.jo

[Python-ideas] Re: join() could add separators at start or end

2023-03-08 Thread Ben Rudiak-Gould
Currently you can write term.join(xs) + term if you want 1, 1, 2, 3, ... terminators when xs has 0, 1, 2, 3, ... elements, and term.join([*xs, '']) # or b'' if you want 0, 1, 2, 3, ... terminators, neither of which is prohibitively annoying. What I don't like about the status quo is t

[Python-ideas] Re: Ampersand operator for strings

2023-03-08 Thread Rob Cliffe via Python-ideas
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

[Python-ideas] join() could add separators at start or end

2023-03-08 Thread Rob Cliffe via Python-ideas
Having had my last proposal shot down in flames, up I bob with another. 😁 It seems to me that it would be useful to be able to make the str.join() function put separators, not only between the items of its operand, but also optionally at the beginning or end. E.g. '|'.join(('Spam', 'Ham', 'Eggs