From 8c94524baf21a3aa3b577bb64bfa42351776fde7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rajmund=20Hru=C5=A1ka?= <rajmund.hruska@gmail.com> Date: Thu, 28 Nov 2024 13:29:08 +0100 Subject: [PATCH] Add equality with arbitrary objects --- ipranges.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ipranges.py b/ipranges.py index bcbef0a..065f966 100644 --- a/ipranges.py +++ b/ipranges.py @@ -26,7 +26,9 @@ class Range(object): return self.high() - self.low() + 1 def __eq__(self, other): - return (self.low() == other.low() and self.high() == other.high()) + if isinstance(other, (IPRangeBase, IPNetBase, IPAddrBase)): + return (self.low() == other.low() and self.high() == other.high()) + return False def __ne__(self, other): return not self.__eq__(other) -- GitLab