[issue44197] [request feature] Itertools extended combinations to limited number of repetition

Dennis Sweeney report at bugs.python.org
Thu May 20 19:37:49 EDT 2021


Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:

How is proposed_function("abcd", max_repeat=3) any different from what you can currently spell as combinations("aaabbbcccddd") ? Or, more generally,

def proposed_function(it, repeats)
    repeated = chain.from_iterable([x] * repeat for x in it)
    return combinations(repeated)

This can easily generalize to specifying the max count of each item.

----------
nosy: +Dennis Sweeney

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44197>
_______________________________________


More information about the Python-bugs-list mailing list