On Mon, Sep 20, 2010 at 2:54 PM, Seth Leija <fazzit...@gmail.com> wrote:
> I need to know how to generate a list of combinations/permutations > (can't remember which it is). Say I have a list of variables: > > [a,b,c,d,...,x,y,z] > > I am curious if there is an optimized way to generate this: > > [[a,b],[a,c],[a,d],...,[x,z],[y,z]] > In Python 2.6 or newer: >>> from itertools import combinations >>> import string >>> print list(combinations(string.lowercase, 2)) Cheers, Ian
-- http://mail.python.org/mailman/listinfo/python-list