Added the possibility of checking equality between users using the unique `id`s.
authorgaros <Gard-Inge.Rosvold@ffi.no>
Thu, 5 Oct 2017 06:52:33 +0000 (08:52 +0200)
committergaros <Gard-Inge.Rosvold@ffi.no>
Thu, 5 Oct 2017 07:01:39 +0000 (09:01 +0200)
tweepy/models.py

index 21449d0374e606525e89f1107f0925a287942dd9..00269ddcf56db349276b67e31381030c4fc2835e 100644 (file)
@@ -201,6 +201,20 @@ class User(Model):
                                        *args,
                                        **kargs)
 
+    def __eq__(self, other):
+        if isinstance(other, User):
+            return self.id == other.id
+
+        return NotImplemented
+
+    def __ne__(self, other):
+        result = self == other
+
+        if result is NotImplemented:
+            return result
+
+        return not result
+
 
 class DirectMessage(Model):