-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathday9classes.py
64 lines (43 loc) · 1.15 KB
/
day9classes.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class Sample:
def someFx(self):
print("Sample class someFx")
__someFx = someFx
class Other(Sample):
def someFx(self):
print("Other class someFx")
otherObj = Other()
otherObj.someFx()
otherObj._Sample__someFx()
print("-"*20)
class Looppy:
def __init__(self,receivedData=[]):
self.data = receivedData
self.index = len(self.data)
def __iter__(self):
return self
def __next__(self):
if self.index == 0:
raise StopIteration
self.index = self.index - 1
return self.data[self.index]
loopObj = Looppy([1,2,3,4,5,6])
for num in loopObj:
print(num)
print("-"*20)
numList = [0,1]
compList = range(0,1)
# for num in compList:
# numList.append(num)
print(numList)
print(list(compList))
import sys
from random import randint
print(f"The size of numList is {sys.getsizeof(numList)} bytes")
print(f"The size of compList is {sys.getsizeof(compList)} bytes")
def digitGenerator(numDigit=1):
for digit in range(0,numDigit):
yield randint(0,9)
testGen = digitGenerator(5000)
for num in digitGenerator(4):
print(num,end='')
print(sys.getsizeof(testGen))