Python tutorial
method | description |
clear | removes all elements |
copy | does shallow-copy |
add | Adds an element into the list.if element already exists do nothing |
remove | removes element,otherwise keyError exction |
pop | Removes arbitrary set element |
update | set1.update(set2), All unique elements from both sets are updated in set1,set2 is unchanged. This is equal to add 2 sets |
union | all elements from both sets |
intersection | elements exists in both sets |
difference | set1-set2, i.e elements from set1, which are not in set2 |
difference_update | Remove all elements from another set from this set |
symetric_difference | Return set with uncommon elements from both sets |
symetric_difference_update | same as Symmetric-difference, but removes LHS set elements, and updates with uncommon elements from both sets. RHS set unchanged |
intersection_update | Same as intersetion, In intersection method returns a new set, but in this case updates set1(LHS) with intersected values, Set2(RHS) unchanged |
issubset | returns True, when set1 elements contained in set2 |
issuperset | returns True when set2 all elements are contained in set2 |
discard | removes element from list |
Both methods are used to remove a element from the Set object.
discard method removes element if found, otherwise do nothing
remove methood also removes element if found, otherwise KeyError exception thrown
ADS