array next pointer
Hrvoje Niksic
hniksic at xemacs.org
Wed Mar 18 05:10:03 EDT 2009
Armin <feng.shaun at gmail.com> writes:
>> Yep, that's what I meant, I forgot the parameter name.
>
> Could you give an example of next() with a sentinel and describe its
> use case please? I have a little trouble understanding what you
> guys mean!
See the thread about reading the file in chunks. Instead of:
while True:
chunk = f.read(1024)
if chunk == '':
break
# your processing here
with sentinel iter, you can write:
for chunk in iter(lambda: f.read(1024), ''):
# your processing here
More information about the Python-list
mailing list