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. '|'.join(('Spam', 'Ham', 'Eggs')) returns > 'Spam|Ham|Eggs' > but it might be useful to make it return one of > '|Spam|Ham|Eggs' > 'Spam|Ham|Eggs|' > '|Spam|Ham|Eggs|' > Compare these two lines: '\n'.join(lines) + '\n' '\n'.join(lines, atEnds=1) The first is not only shorter, it's more clear what it's doing. I'd have to look up everytime to remember whether the value atEnds=1 is doing the right thing. It's just IMHO not valuable enough for the cost. Not every potential optimization is worth including in the core language or the stdlib (if this even is an optimization). --- Bruce
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ZDIAVITFHARQG57ZZ5EDXEGT7GYDAKJL/ Code of Conduct: http://python.org/psf/codeofconduct/