-
Notifications
You must be signed in to change notification settings - Fork 0
/
dunder function __cos__.py
43 lines (37 loc) · 1.04 KB
/
dunder function __cos__.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
42
43
class ASAPMob:
def __init__(self):
self._members = [
"Jan Kowalski",
"Anna Nowak",
"Piotr Wiśniewski",
"Katarzyna Dąbrowska",
"Andrzej Lewandowski",
"Magdalena Wójcik",
"Michał Kamiński",
"Joanna Kowalczyk",
"Tomasz Zieliński",
"Małgorzata Szymańska",
"Paweł Woźniak",
"Agnieszka Kozłowska",
"Marcin Jankowski",
"Dorota Włodarczyk",
"Krzysztof Wojciechowski",
"Ewa Adamczyk",
"Bartosz Nowicki",
"Aleksandra Jóźwiak",
"Łukasz Grabowski",
"Monika Pawłowska"
]
def __len__(self):
return len(self._members)
def __getitem__(self, key):
if isinstance(key, int):
return self._members.pop(key)
raise TypeError('not a number')
# def __contains__(self, member):
# return member in self._members
asap_mob = ASAPMob()
print(len(asap_mob))
print("goes solo: ", asap_mob[4])
print(len(asap_mob))
print("Monika" in asap_mob)