Changes by Terry J. Reedy tjre...@udel.edu:
--
resolution: - rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22360
___
New submission from Christoph Wruck:
Currently we have a split function which splits a str/bytestr into
chunks of their underlying data. This works great for the most tivial jobs.
But there is no possibility to pass an offset parameter into the split
function which indicates the next
Steven D'Aprano added the comment:
I'm afraid I don't understand the purpose of this feature request, or what the
behaviour is.
You show a simple example:
s = 'abc;;def;hij'
s.split(';', offset=1)
['abc', ';def', 'hij']
but I don't understand why you want to keep the second semi-colon. I
Serhiy Storchaka added the comment:
Such problems are solved by using regular expressions.
re.findall('(?:^|(?=;)).?[^;]*', 'abc;;def;hij')
['abc', ';def', 'hij']
--
nosy: +serhiy.storchaka
___
Python tracker rep...@bugs.python.org
Christoph Wruck added the comment:
Hi Steven
exactly - you're right with this.
'spam--eggs--cheesetoast'.split('-', offset=1)
-- ['spam', '-eggs', '-cheese', '-', '-toast']
'spam--eggs--cheese--toast'.split('-', offset=8)
-- ['spam', '-eggs--cheese', '-toast']
Okay - the name offset
R. David Murray added the comment:
If you want to do complex splitting, the supported way to do so is re.split.
Feel free to take this to python-ideas if you think there is sufficient reason
for baking a particular additional splitting functionality into str.split.
--
nosy:
Christoph Wruck added the comment:
Serhiy, you will be right if you've to split a complex string such spliting
strings with more than one separator. In this case I would prefer a regex bases
solution too. Otherwise we could actually use the re-lib for every of those
jobs without using the
Christoph Wruck added the comment:
David, I'll reflect on it. @ALL - Thank's for all answers.
Should I close this ticket?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22360
___