Last active
October 4, 2015 12:09
-
-
Save poros/4a3d43d9b9c9192fa59f to your computer and use it in GitHub Desktop.
Call a function until a sentinel value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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