Excellent. By symmetry, I see that "list" casts the set back into a list.
I wonder why list has not been extended with the same (difference, interesection) methods? Casting to set looks a little kludgy: c = list(set(a)-set(b)) I wonder if that is clearer than the explicit loop? Steve. "Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > En Thu, 23 Aug 2007 23:54:14 -0300, bambam <[EMAIL PROTECTED]> escribi?: > >> After examining your suggestion, I realised that another thing >> I am interested in could be generalised: I want the complement >> of the set of ports in pages, given a universal set in tempList. >> Ignoring the break condition for the moment, and my problem >> with int(port)/str(port), would you have offered a different solution >> if I had asked for the relative complement of a small set? >> >> a= ['a','b','c'] >> b= ['b'] >> c= a-b #set theoretic difference, a\b, a.~b, ['a','c'] > > If you want a set - just use a set: > > py> a = set(['a','b','c']) > py> b = set(['b']) > py> c = a-b > py> c > set(['a', 'c']) > > -- > Gabriel Genellina > -- http://mail.python.org/mailman/listinfo/python-list