-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
68 lines (57 loc) · 1.27 KB
/
test.py
File metadata and controls
68 lines (57 loc) · 1.27 KB
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
65
66
67
68
def genipport(iplist, portlist):
#IPs = genip(iplist)
IPs = (iplist)
for ip in IPs:
#Ports = genport(portlist)
Ports = (portlist)
for port in Ports:
yield (ip,port)
IPList = [11,2,32,435,2,3,55,6,5,4,443,333,2244,55]
PortList = [11,4,4,555,6,67777,7664,33,22,223,44,44,44]
ipWITHport = genipport(IPList, PortList)
item = next(ipWITHport)
#print item
def fab(max):
n, a, b = 0, 0, 1
L = []
while n < max:
L.append(b)
a, b = b, a + b
n = n + 1
return L
#print fab(12)
def fab1(max):
n, a, b = 0, 0, 1
while n < max:
yield b
a, b = b, b + a
n = n + 1
f = fab1(5)
# print n
class Fab(object):
def __init__(self, max):
self.max = max
self.n, self.a, self.b = 0, 0, 1
def __inter__(self):
return self
def next(self):
if self.n < self.max:
r = self.b
self.a, self.b = self.b, self.a + self.b
self.n = self.n + 1
return r
raise StopIteration()
def read_file(fpath):
BLOCK_SIZE = 10
with open(fpath, 'rb') as f:
while True:
#block = f.read(BLOCK_SIZE)
block = f.readline()
if block:
yield block
else:
return
data = read_file('/root/test.py')
for d in data:
print d
print 111111111111111111