Sye van der Veen added the comment: In the sep!=None case, there are existing alternatives to prune=True that aren't many more keystrokes:
>>> ''.split(' ', prune=True) [] >>> [x for x in ''.split(' ') if x] [] >>> list(filter(bool, ''.split(' '))) # or drop list() and use the iterator >>> directly [] This becomes even fewer keystrokes for users that create a prune() or split_prune() function. For the sep==None case, I agree there are no alternatives to prune=False (aside from rolling your own split function). However, instead of prune, what if sep accepted a tuple of strings, similar to startswith. In this case, each string would be considered one possible, yet distinct, delimiter: >> ''.split(prune=False) [''] >> ''.split((' ', '\t')) # typical whitespace [''] >> ''.split(tuple(string.whitespace)) # ASCII whitespace [''] Once again, this becomes even easier for users that create a split_no_prune() function, or that assign tuple(string.whitespace) to a variable. It would also nicely handle strings with non-homogeneous delimiters: >>> '1?2,,3;'.split((',', ';', '?')) ['1', '2', '', '3', ''] I personally find the 0-argument str.split() one of the great joys of Python. It's common to have to split out words from a sentence, and having that functionality just 8 characters away at all times has been very useful. ---------- nosy: +syeberman _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28937> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com