Re: complementary lists?

2009-04-29 Thread Bryan
the complementary subset to y z=[2,3,5,6,8,9] ? > > >> The reason I ask is because I have a generator function that generates > >> a list of tuples and I would like to divide this list into > >> complementary lists. > > > z = [u for u in x if u not in y] >

Re: complementary lists?

2009-04-29 Thread Bryan
the complementary subset to y z=[2,3,5,6,8,9] ? > > >> The reason I ask is because I have a generator function that generates > >> a list of tuples and I would like to divide this list into > >> complementary lists. > > > z = [u for u in x if u not in y] >

Re: complementary lists?

2009-04-28 Thread Arnaud Delobelle
reason I ask is because I have a generator function that generates >> a list of tuples and I would like to divide this list into >> complementary lists. > > z = [u for u in x if u not in y] > > or > > z = [u for u in x if u not in set(y)] The above will evaluate set(y

Re: complementary lists?

2009-04-28 Thread Paul Rubin
Ross writes: > If I have a list x = [1,2,3,4,5,6,7,8,9] and another list that is a > subset of x: y = [1,4,7] , is there a quick way that I could return > the complementary subset to y z=[2,3,5,6,8,9] ? >>> x = [1,2,3,4,5,6,7,8,9] >>> y = [1,4,7] >>> print sorted(set(x)-set(y))

Re: complementary lists?

2009-04-28 Thread Mensanator
r function that generates > a list of tuples and I would like to divide this list into > complementary lists. >>> s = set([1,2,3,4,5,6,7,8,9]) >>> s.difference(set([1,4,7])) set([2, 3, 5, 6, 8, 9]) -- http://mail.python.org/mailman/listinfo/python-list

Re: complementary lists?

2009-04-28 Thread Kay Schluehr
r function that generates > a list of tuples and I would like to divide this list into > complementary lists. z = [u for u in x if u not in y] or z = [u for u in x if u not in set(y)] Since you are dealing with tuples and a natural order might not be that relevant you can also set objects in th

complementary lists?

2009-04-28 Thread Ross
divide this list into complementary lists. -- http://mail.python.org/mailman/listinfo/python-list