-
Notifications
You must be signed in to change notification settings - Fork 0
/
Luts_2.py
40 lines (30 loc) · 1.04 KB
/
Luts_2.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
class MyList:
def __init__(self, mylist):
self.mylist = list(mylist)
def __add__(self, other):
return MyList(self.mylist + other)
def __getitem__(self, other):
# if isinstance(other, int):
# return self.mylist[other] # индексирование
# else:
# return self.mylist[other] # срез
return self.mylist[other]
def append(self, other):
return self.mylist.append(other)
def sort(self):
return self.mylist.sort()
def __getslice__(self, start, stop):
return MyList(
self.mylist[start:stop])
class MyListSub(MyList):
calls_number = 0
def __init__(self, mylist):
MyList.__init__(self, mylist)
self.adds_number = 0
def __add__(self, other):
print(f"method add with argument {other}")
self.adds_number += 1
MyListSub.calls_number += 1
return MyList.__add__(self, other)
def call_add_calculator(self):
return self.adds_number, self.calls_number