Christoph Wruck added the comment:

Hi Steven

exactly - you're right with this.

'spam--eggs--cheese----toast'.split('-', offset=1)
--> ['spam', '-eggs', '-cheese', '-', '-toast']

'spam--eggs--cheese--toast'.split('-', offset=8)
--> ['spam', '-eggs--cheese', '-toast']

Okay - the name "offset" might be an unfortunate choice and you are right that 
this could be hard to understand for a caller. 

One more examples:

The following removes all escape signs to process the octal escape sequences in 
a second way if the first three characters are digits.

'spam\\055\\\\055-eggs-\\\\rest'.split('\\', offset=1)
--> ['spam', '055', '\\055-eggs-', '\\rest']

# could speed up the split built-in func if a caller knows that every chunk is 
3 chars long?
'tic-tac-toe'.split('-', offset=3)

A caller could use the offset parameter to keep all separators between
the last found and offset if it's a part of a chunk. Or if he awaiting a 
separator followed by itself which should be keeped - in doubt with the same 
length of separator.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22360>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to