Skip to content

Commit ced2835

Browse files
committed
yield: update fab.py
1 parent d1cbca9 commit ced2835

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

yield/fab.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,17 @@ def fab2(max):
6666

6767
print(isinstance(fab2, types.GeneratorType))
6868
print(isinstance(fab2(5), types.GeneratorType))
69+
70+
from collections import Iterable
71+
print(isinstance(fab2, Iterable))
72+
print(isinstance(fab2(5), Iterable))
73+
74+
def read_file(fpath):
75+
BLOCK_SIZE = 1024
76+
with open(fpath, 'rb') as f:
77+
while True:
78+
block = f.read(BLOCK_SIZE)
79+
if block:
80+
yield block
81+
else:
82+
return

0 commit comments

Comments
 (0)