From 8f5313cfee4b5279a46b2d7406f01bedb7c981a9 Mon Sep 17 00:00:00 2001 From: garos Date: Thu, 5 Oct 2017 08:52:33 +0200 Subject: [PATCH] Added the possibility of checking equality between users using the unique `id`s. --- tweepy/models.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tweepy/models.py b/tweepy/models.py index 21449d0..00269dd 100644 --- a/tweepy/models.py +++ b/tweepy/models.py @@ -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): -- 2.25.1