[issue28937] str.split(): remove empty strings when sep is not None
Emanuel Barry
report at bugs.python.org
Sun Dec 11 10:26:42 EST 2016
Emanuel Barry added the comment:
I understand the feeling. However, in a project I maintain, we want the other way around - to be able to never have an empty list, even if the string is empty (we resorted to using re.split in the end, which has this behaviour). Consider:
rest = re.split(" +", rest)[0].strip()
This gives us None-like behaviour in splitting, at the cost of not actually using str.split.
I'm +1 on the idea, but I'd like some way to better generalize str.split use (not everyone knows you can pass None and/or an integer).
(At the same time, the counter arguments where str has too many methods, or that methods shouldn't do too much, also apply here.)
But I don't like bikeshedding too much, so let's just count me as +1 for your way, if there's no strong momentum for mine :)
----------
nosy: +ebarry
type: -> enhancement
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28937>
_______________________________________
More information about the Python-bugs-list
mailing list