Skip to content

Instantly share code, notes, and snippets.

@poros
Last active October 4, 2015 12:09
Show Gist options
  • Save poros/4a3d43d9b9c9192fa59f to your computer and use it in GitHub Desktop.
Save poros/4a3d43d9b9c9192fa59f to your computer and use it in GitHub Desktop.
Call a function until a sentinel value
blocks = []
while True:
block = f.read(32)
if block == '':
break
blocks.append(block)
from functools import partial
blocks = []
for block in iter(partial(f.read, 32), ''):
blocks.append(block)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment