Carl Banks wrote: <snip> > > The function can be extended to allow arbitrary arguments. Here's a > non-minmal recursive version. > > def cartesian_product(*args): > if len(args) > 1: > for item in args[0]: > for rest in cartesian_product(*args[1:]): > yield (item,) + rest > elif len(args) == 1: > for item in args[0]: > yield (item,) > else: > yield () > >
Very nice. -- http://mail.python.org/mailman/listinfo/python-list