Update the set, removing any elements from other which are not in both sets.
(self, other)
| 115 | self.add(item) |
| 116 | |
| 117 | def intersection_update(self, other): |
| 118 | """Update the set, removing any elements from other which are not |
| 119 | in both sets. |
| 120 | """ |
| 121 | |
| 122 | if not isinstance(other, Set): |
| 123 | raise ValueError("other must be a Set instance") |
| 124 | if self is other: # lgtm[py/comparison-using-is] |
| 125 | return |
| 126 | # we make a copy of the list so that we can remove items from |
| 127 | # the list without breaking the iterator. |
| 128 | for item in list(self.items): |
| 129 | if item not in other.items: |
| 130 | del self.items[item] |
| 131 | |
| 132 | def difference_update(self, other): |
| 133 | """Update the set, removing any elements from other which are in |
no outgoing calls