[issue43280] additional argument for str.join()

Dennis Sweeney report at bugs.python.org
Sat Feb 20 16:37:56 EST 2021


Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:

This seems like a very specific use case. Too specific IMO for a method on all string objects for anyone using Python anywhere in the world. Why not just write a function like this?

    def my_join(strings, sep=", ", last_sep=", and "):
        strings = list(strings)
        return sep.join(strings[:-1]) + last_sep + strings[-1]

    >>> my_join(["one", "two", "three"])
    'one, two, and three'

----------
nosy: +Dennis Sweeney

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43280>
_______________________________________


More information about the Python-bugs-list mailing list