Override TLObject's __eq__ and __ne__ methods

This commit is contained in:
Lonami Exo 2018-02-01 12:10:03 +01:00
parent add122bfe7
commit fbd53e2126

View File

@ -144,6 +144,12 @@ class TLObject:
def on_response(self, reader): def on_response(self, reader):
self.result = reader.tgread_object() self.result = reader.tgread_object()
def __eq__(self, o):
return isinstance(o, type(self)) and self.to_dict() == o.to_dict()
def __ne__(self, o):
return not isinstance(o, type(self)) or self.to_dict() != o.to_dict()
def __str__(self): def __str__(self):
return TLObject.pretty_format(self) return TLObject.pretty_format(self)