Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2011-06-02 05:35:37 -0500

kcrisman gravatar image

iterating over a combinatorial class

It is somewhat annoying that len and next don't do what you think with combinatorial classes. Is there any more Pythonic (e.g. list comprehension) way to do the following?

prof = [1,3,2,0,0,3]
L = []
P = Permutations(3)
Q = P.__iter__()
for j in range(P.cardinality()):
    tp =
    for i in range(prof[j]):

Part of the issue is that I would really rather not use Q, since it is "used up" when I'm done. I really want something that is succinct, but I just could not find a way to do it.