Imagine you have two lists.
list1 = ['a', 'b', 'c']
list2 = ['x', 'y']
what is the function that gives you back every possible function from the domain of list1 to the codomain of list2? The answer in this case would be
[ [('a', 'x'), ('b', 'y')],
[('a', 'x'), ('c', 'y')],
[('b', 'x'), ('a', 'y')],
[('b', 'x'), ('c', 'y')],
[('c', 'x'), ('a', 'y')],
[('c', 'x'), ('b', 'y')] ]
This is a more general case of this question and answer which is the answer to this question when list1 and list2 are the same size.
Assume you don't know which is bigger, and either list could be 0, 1, or many elements. Preferably this should be expressible as some combination of itertools functions.
--EDITS--
The best I have so far is:
def everyPossibleAssignment(A, B):
if len(A) < len(B): return [list(zip(A, P)) for P in permutations(B, len(A))]
else: print "A must be smaller in size than B"
but I'm sure there's better.