Path: blob/master/venv/Lib/site-packages/lxml/html/_setmixin.py
811 views
try:1from collections.abc import MutableSet2except ImportError:3from collections import MutableSet456class SetMixin(MutableSet):78"""9Mix-in for sets. You must define __iter__, add, remove10"""1112def __len__(self):13length = 014for item in self:15length += 116return length1718def __contains__(self, item):19for has_item in self:20if item == has_item:21return True22return False2324issubset = MutableSet.__le__25issuperset = MutableSet.__ge__2627union = MutableSet.__or__28intersection = MutableSet.__and__29difference = MutableSet.__sub__30symmetric_difference = MutableSet.__xor__3132def copy(self):33return set(self)3435def update(self, other):36self |= other3738def intersection_update(self, other):39self &= other4041def difference_update(self, other):42self -= other4344def symmetric_difference_update(self, other):45self ^= other4647def discard(self, item):48try:49self.remove(item)50except KeyError:51pass5253@classmethod54def _from_iterable(cls, it):55return set(it)565758