Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. def read_chunks(filename, mode="r", chunk_size=32):
  2. with open(filename, mode) as f:
  3. while True:
  4. data = f.read(chunk_size)
  5. if not data:
  6. break
  7. yield data
  8.  
  9.  
  10. def main():
  11. filename = "/Users/bob.smith/files/really_really_big.dat"
  12. for chunk in read_chunks(filename):
  13. print(chunk)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement