Skip to content

Commit e02b051

Browse files
committed
Add InputDevice.__ne__ to fix device != comparison on Python 2
1 parent ee0e680 commit e02b051

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎evdev/device.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ def __eq__(self, other):
258258
'''
259259
return isinstance(other, self.__class__) and self.info == other.info
260260

261+
def __ne__(self, other):
262+
# Python 2 compatibility. Python 3 automatically negates the value of
263+
# __eq__, in case __ne__ is not defined.
264+
return not self == other
265+
261266
def __str__(self):
262267
msg = 'device {}, name "{}", phys "{}"'
263268
return msg.format(self.fn, self.name, self.phys)

0 commit comments

Comments
 (0)