I want to create an iterator that returns progressively larger products of another iterator, i.e., return first the products with repeat=1, then repeat=2, and so on. In code, it would be:
infinite_product('AB')
-> ('A'), ('B'), ('AA'), ('AB'), ('BA'), ('BB'), ('AAA'), ('AAB'), ('ABA')...
The closest function described in itertools documentation is powerset(), which I was unable to adapt because the iterator is supposed to be infinite and using itertools.count() as the repeat argument is not possible (TypeError: 'itertools.count' object cannot be interpreted as an integer).
Is it possible to do something similar with itertools, without writing nested loops?