Set Methods
Methods available on Python set objects.
set.add()
Adds an element to a set, creating a unique collection of hashable objects
set.add(elem) set.clear()
Removes all elements from a set, leaving it empty
set.clear() set.copy()
Creates a shallow copy of a set, returning a new set with the same elements
set.copy() set.difference_update()
Removes all elements from this set that are also in another set, modifying the original set in place
set.difference_update(*others) set.difference()
Returns a new set containing elements in the calling set but not in the iterables
set.difference(*others) set.discard()
Removes an element from a set if it exists, without raising an error if the element is not found
set.discard(elem) set.intersection()
Returns a new set containing only elements that exist in all sets
set.intersection(*others) set.isdisjoint()
Check if a set has no elements in common with another set
set.isdisjoint(other) set.issubset()
Check whether all elements of one set are contained in another set
set.issubset(other) set.issuperset()
Check if a set contains all elements of another set
set.issuperset(other) set.pop()
Removes and returns an arbitrary element from a set, raising KeyError if the set is empty
set.pop() set.remove()
Removes an element from a set, raising KeyError if the element is not found
set.remove(elem) set.symmetric_difference_update()
Updates a set in-place with elements in either set but not in both
set.symmetric_difference_update(other) set.symmetric_difference()
Returns a new set containing elements in either set but not in both
set.symmetric_difference(other) set.union()
Returns a new set containing all elements from multiple sets
set.union(*others) set.update()
Adds all elements from one or more iterables to a set, modifying it in place
set.update(*others)