-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathword.py
More file actions
24 lines (22 loc) · 729 Bytes
/
Copy pathword.py
File metadata and controls
24 lines (22 loc) · 729 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
class Word(str):
'''The Word class inherits from the str class.
Which means it gets everything from the str
class plus whatever it defines. So we will
redefine >, <, >=, <= so that a Word is
compared by length, not alphabetically.
'''
def __gt__(self, other):
print('borch gt')
return len(self) > len(other)
def __lt__(self, other):
print('borch lt')
return len(self) < len(other)
def __ge__(self, other):
print('borch ge')
return len(self) >= len(other)
def __le__(self, other):
print('borch le')
return len(self) <= len(other)
def __eq__(self, other):
print('borch eq')
return len(self) == len(other)