[issue10476] __iter__ on a byte file object using a method to return an iterator

Raymond Hettinger report at bugs.python.org
Sun Nov 21 01:51:52 CET 2010


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

FWIW, an idiom I use in Py2.x is:

   for block in iter(partial(f.read, BLKSIZ), ''):
        . . .

This works with both single bytes at time and multiple bytes at a time.

----------
nosy: +rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10476>
_______________________________________


More information about the Python-bugs-list mailing list