New submission from Harry Coin <hgc...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue37620>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to