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 would have
thought this would be more useful:
# treat runs of the separator as if it were a single separator
['abc', 'def', 'hij']
It might help if you explain under what circumstances you would use this. Also,
how does the caller choose a value for offset? Say, I read a string from a data
file, or from the user. How do I know what offset to use?
I'm not sure I understand what this offset parameter is supposed to do in
general. Here are some examples showing what I think you want, can you tell me
if I'm right?
'spam--eggs--cheese----toast'.split('-', offset=1)
--> ['spam', '-eggs', '-cheese', '-', '-toast']
'spam--eggs--cheese--toast'.split('-', offset=8)
--> ['spam', '-eggs--cheese', '-toast']
----------
nosy: +steven.daprano
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22360>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com