md5sum: use `iter(callable, sentinel)` instead of while True
authorAugie Fackler <augie@google.com>
Fri, 05 Aug 2016 14:00:56 -0400
changeset 29731 8d1cdee372e6
parent 29730 4d23cd6e2219
child 29732 0806fa2a39d8
md5sum: use `iter(callable, sentinel)` instead of while True This is functionally equivalent, but is a little more concise.
tests/md5sum.py
--- a/tests/md5sum.py	Fri Aug 05 14:00:46 2016 -0400
+++ b/tests/md5sum.py	Fri Aug 05 14:00:56 2016 -0400
@@ -34,10 +34,7 @@
 
     m = md5()
     try:
-        while True:
-            data = fp.read(8192)
-            if not data:
-                break
+        for data in iter(lambda: fp.read(8192), ''):
             m.update(data)
     except IOError as msg:
         sys.stderr.write('%s: I/O error: %s\n' % (filename, msg))