[issue44197] [request feature] Itertools extended combinations to limited number of repetition
Tim Peters
report at bugs.python.org
Thu May 20 22:00:05 EDT 2021
Tim Peters <tim at python.org> added the comment:
Dennis, combinations("aaabbbcccddd") isn't a valid call - the function requires a "how many?" argument too. If, e.g., we were asking for groups of 4, then combinations("aaabbbcccddd", 4) generates the 4-tuple ('a', 'b', 'c', 'd') 81 (3**4) times, while the OP presumably only wants to get it once.
OTOH, combinations_with_replacement("abcd", 4) can generate tuples with more than 3 repetitions of a given element.
The linked StackOverflow entry gives an efficient "real solution", but I agree with its author's final comment: "It is much too specialized for itertools". Indeed, it seems too obscure and special-purpose to me to even qualify as a reasonable candidate for an itertools doc "recipe".
----------
nosy: +tim.peters
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44197>
_______________________________________
More information about the Python-bugs-list
mailing list