From: Raymond Hettinger Date: Wed, 30 Jan 2008 00:01:07 +0000 (+0000) Subject: Add isdisjoint() to the Set/MutableSet ABCs. X-Git-Tag: v2.6a1~343 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=abf3fcf39fb3bff4d347296a083a4c62d515dacd;p=python Add isdisjoint() to the Set/MutableSet ABCs. --- diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py index ac967b2350..3a84b965b4 100644 --- a/Lib/_abcoll.py +++ b/Lib/_abcoll.py @@ -177,6 +177,12 @@ class Set: return NotImplemented return self._from_iterable(value for value in other if value in self) + def isdisjoint(self, other): + for value in other: + if value in self: + return False + return True + def __or__(self, other): if not isinstance(other, Iterable): return NotImplemented