?
=?ISO-8859-1?Q?Mickel_Gr=F6nroos?=
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.)
Here is what I would like to have:
list1 = [1,2,3]
list2 = [3,4]
list3 = list1.intersection(list2)
(list3 is now [3])
list3 = list1.difference(list2)
(list3 is now [1,2])
list3 = list2.difference(list1)
(list3 is now [4])
I realize I could quite easily implement this myself, but I was hoping for
a built-in solution.
Cheers,
/Mickel
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.)
Here is what I would like to have:
list1 = [1,2,3]
list2 = [3,4]
list3 = list1.intersection(list2)
(list3 is now [3])
list3 = list1.difference(list2)
(list3 is now [1,2])
list3 = list2.difference(list1)
(list3 is now [4])
I realize I could quite easily implement this myself, but I was hoping for
a built-in solution.
Cheers,
/Mickel