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 mark.dickinson
Recipients SilentGhost, lovi, mark.dickinson
Date 2019-12-14.18:22:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576347757.27.0.580402265329.issue39045@roundup.psfhosted.org>
In-reply-to
Content
For the record, this is an easy application of itertools.combinations:

>>> def segment(s, m):
...     for c in itertools.combinations(range(1, len(s)), m-1):
...         yield tuple(s[i:j] for i, j in zip((0,)+c, c+(len(s),)))
... 
>>> list(segment("12345", m=3))
[('1', '2', '345'), ('1', '23', '45'), ('1', '234', '5'), ('12', '3', '45'), ('12', '34', '5'), ('123', '4', '5')]
History
Date User Action Args
2019-12-14 18:22:37mark.dickinsonsetrecipients: + mark.dickinson, SilentGhost, lovi
2019-12-14 18:22:37mark.dickinsonsetmessageid: <1576347757.27.0.580402265329.issue39045@roundup.psfhosted.org>
2019-12-14 18:22:37mark.dickinsonlinkissue39045 messages
2019-12-14 18:22:37mark.dickinsoncreate