> def cross_nodups(*args): > 'Cross product after eliminating repeat elements, keeping constant > size' > ans = [[]] > for arg in args: > ans = [x+[y] for x in ans for y in arg if y not in x] > return ans > > def choose_first(obj1, *args): > 'Assume a choice of a first object' > return cross_nodups(frozenset((obj1,)), *args[1:])
Oops, crap, I pasted the unchanged cross_nodups() you wrote. My adjusted variety: def cross_nodups(*args): 'Cross product after eliminating repeat elements, keeping constant size' ans = [[]] for arg in args: ans = [frozenset(list(x)+[y]) for x in ans for y in arg if y not in x] return set(ans) Anyhow, thank you! :) -- http://mail.python.org/mailman/listinfo/python-list