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.

classification
Title: Add str.split_iter function
Type: enhancement Stage: resolved
Components: Unicode Versions: Python 3.10
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Add a version of str.split which returns an iterator
View: 17343
Assigned To: Nosy List: ezio.melotti, serhiy.storchaka, steven.daprano, uwinx, vstinner
Priority: normal Keywords:

Created on 2021-01-03 13:09 by uwinx, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg384270 - (view) Author: Martin Winks (uwinx) Date: 2021-01-03 13:09
Split string by given separator and return iterator as a result.

The naive and not very efficient solution would be using current str.split:

def split_iter(self: str, sep: str) -> 'Iterator[str]':
    return iter(self.split(sep))

Probably, need we'll some better solution without allocating new list.
msg384274 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2021-01-03 13:40
I am pretty sure this has been discussed and rejected on the Python-Ideas mailing list before.

If not rejected, the idea didn't go very far. You may wish to search the mailing list archives for previous discussions.

Either way, I think this should be discussed on Python-Ideas, to see if there is a consensus on this, and whether or not this is a large enough change that it needs a PEP.
msg384275 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2021-01-03 13:43
See also discussion here: #17343
msg384276 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-03 13:58
Issue17343 mentions also a separate method str.itersplit, so I close this issue as a duplicate.
History
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 86982
2021-01-03 13:58:27serhiy.storchakasetstatus: open -> closed

superseder: Add a version of str.split which returns an iterator

nosy: + serhiy.storchaka
messages: + msg384276
resolution: duplicate
stage: resolved
2021-01-03 13:43:14steven.dapranosetmessages: + msg384275
2021-01-03 13:40:58steven.dapranosetnosy: + steven.daprano
messages: + msg384274
2021-01-03 13:09:42uwinxcreate