-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (34 loc) · 982 Bytes
/
main.py
File metadata and controls
47 lines (34 loc) · 982 Bytes
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
42
43
44
45
46
47
class DemocracyDigit(int):
def _is_my_political_pal(self, other):
return type(other) == DemocracyDigit
def _we_are_the_same(self, other):
if self._is_my_political_pal(other):
return False
return True
def _we_are_equal(self, other):
if self._is_my_political_pal(other):
return True
return False
def __eq__(self, other):
return self._we_are_equal(other)
def __ne__(self, other):
return self._we_are_the_same(other)
def __ge__(self, other):
return self._we_are_the_same(other)
def __le__(self, other):
return self._we_are_the_same(other)
def __lt__(self, other):
return self._we_are_the_same(other)
def __gt__(self, other):
return self._we_are_the_same(other)
a = DemocracyDigit(10)
b = DemocracyDigit(999)
c = 10
print(a != b)
print(a == b)
print(a >= b)
print(a <= b)
print(b > a)
print(b < a)
print(c == a)
print(c == b)