[issue28937] str.split(): allow removing empty strings (when sep is not None)

Mark Bell report at bugs.python.org
Tue May 18 13:07:52 EDT 2021


Mark Bell <mark00bell at googlemail.com> added the comment:

> suggests that empty strings don't count towards maxsplit

Thank you for the confirmation. Although just to clarify I guess you really mean "empty strings *that are dropped from the output* don't count towards maxsplit". Just to double check this, what do we expect the output of

    '   x y z'.split(maxsplit=1, keepempty=True)

to be?

I think it should be ['', '  x y z'] since in this case we are retaining empty strings and they should count towards the maxsplit.

(In the current patch this crashes with a core dump since it tries to write to unallocated memory)

----------

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


More information about the Python-bugs-list mailing list