iter(lambda:f.read(8192),'')
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Feb 25 22:40:29 EST 2008
En Sun, 24 Feb 2008 10:18:31 -0200, Dustan <DustanGroups at gmail.com>
escribió:
> On Feb 24, 5:11 am, gert <gert.cuyk... at gmail.com> wrote:
>> what is the difference between iter(lambda:f.read(8192), ') and
>> iter(f.read(8192),'') ?
>
> iter(lambda:f.read(8192), '') (what you probably meant) is what it
> looks like: iter(some_func, '').
Just to make it more clear, and guessing the original context:
f = open(...)
for data in iter(lambda: f.read(8192), ''):
do_something_with(data)
is the way to iterate over a file in blocks of 8192 bytes each.
--
Gabriel Genellina
More information about the Python-list
mailing list