This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cwr
Recipients cwr, serhiy.storchaka, steven.daprano
Date 2014-09-08.12:43:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1410180224.21.0.749597183232.issue22360@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-09-08 12:43:44cwrsetrecipients: + cwr, steven.daprano, serhiy.storchaka
2014-09-08 12:43:44cwrsetmessageid: <1410180224.21.0.749597183232.issue22360@psf.upfronthosting.co.za>
2014-09-08 12:43:44cwrlinkissue22360 messages
2014-09-08 12:43:43cwrcreate