Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You don't have a set to begin with. CartesianProduct returns a special object. That object automatically converts to a list of lists when you pass it to Subsets. Then Subsets goes through that list of lists, and gets confused by the lists inside - it cannot make subsets out of them, because lists are not hashable. One way around is to use tuples instead of lists:

def Z(m,n):
    return CartesianProduct(IntegerRange(m),IntegerRange(n))
print Subsets(map(tuple,Z(2,2)))