Standard ways to get union, intersection, difference of lists?
Paul Rudin
paul_rudin at scientia.com
Thu Jun 26 05:15:38 EDT 2003
>>>>> "Mickel" == Mickel Grönroos <mickel at csc.fi> writes:
> Hi! Are there any standard list methods for getting the
> intersection and difference of two lists? (The union is easy
> ("list1.extend(list2)"), unless you want it to contain unique
> values.)
[snip]
> I realize I could quite easily implement this myself, but I was
> hoping for a built-in solution.
You might want to take a look at the sets module in Python 2.3. It's
not exactly what you ask for since sets.Sets are not lists - but they
do support these operations and can easily be converted to or from
lists.
More information about the Python-list
mailing list