-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path100-my_int.py
41 lines (31 loc) · 968 Bytes
/
100-my_int.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python3
"""
This module contains the MyInt class which inherits from int.
Classes:
MyInt: Represents an integer with inverted == and != operators.
"""
class MyInt(int):
"""
Represents an integer with inverted == and != operators.
Inherits from int.
"""
def __eq__(self, other):
"""
Inverts the == operator.
Args:
other (int): The integer to compare with.
Returns:
bool: True if self and other are not equal, False otherwise.
"""
# Use the != operator from the parent class (int)
return super().__ne__(other)
def __ne__(self, other):
"""
Inverts the != operator.
Args:
other (int): The integer to compare with.
Returns:
bool: True if self and other are equal, False otherwise.
"""
# Use the == operator from the parent class (int)
return super().__eq__(other)