Message226577
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. |
|
Date |
User |
Action |
Args |
2014-09-08 12:43:44 | cwr | set | recipients:
+ cwr, steven.daprano, serhiy.storchaka |
2014-09-08 12:43:44 | cwr | set | messageid: <1410180224.21.0.749597183232.issue22360@psf.upfronthosting.co.za> |
2014-09-08 12:43:44 | cwr | link | issue22360 messages |
2014-09-08 12:43:43 | cwr | create | |
|