[issue37620] str.split(sep=None, maxsplit=-1,any=False)
Harry Coin
report at bugs.python.org
Thu Jul 18 09:59:00 EDT 2019
New submission from Harry Coin <hgcoin at gmail.com>:
When first I read the str.split documentation I parsed it to mean
'ab\t cd ef'.split(sep=' \t') --> ['ab','cd','ef']
Especially as the given example in the docs with the <> would have led to the given result read the way I read it.
I suggest adding a parameter 'any=False' which by default gives the current behavior. But when True treats each character in the sep string as a delimiter and eliminates any combination of them from the resulting list.
The use cases are many, for example parsing the /etc/hosts file where we see an address, some white space that could be any combination of \t and ' ' followed by more text.
One could imagine 'abc \tdef, hgi,jlk'.split(', \t',any=True) -> ['abc','def','hgi','jlk'] being used quite often.
----------
components: Library (Lib)
messages: 348116
nosy: hcoin
priority: normal
severity: normal
status: open
title: str.split(sep=None, maxsplit=-1,any=False)
type: enhancement
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37620>
_______________________________________
More information about the Python-bugs-list
mailing list