set.difference_update()
set.difference_update() is a Python method in the Set Methods category. Removes all elements that are in others in place. The syntax is set.difference_update(*others). Returns: None. A typical example: s = {1, 2, 3}
s.difference_update({2})
# s = {1, 3}. A close sibling is set.add(), which adds an element to the set if not already present. A close sibling is set.remove(), which removes element x; raises KeyError if not found. A close sibling is set.discard(), which removes element x if present (does nothing if not found). A close sibling is set.pop(), which removes and returns an arbitrary element. Raises KeyError if empty. More about this category: Set methods for collection operations — union, intersection, difference, and more. For a broader walkthrough, read the Set Methods guide. Related Set Methods entries: set.add(), set.remove(), set.discard(), set.pop(), set.clear(), set.union(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.