Message128238
This code fragment from the documentation of iter() doesn't work as intended. Change "STOP" to "STOP\n". Maybe also check for EOF as it hangs.
with open("mydata.txt") as fp:
for line in iter(fp.readline, "STOP"):
process_line(line)
Or maybe this makes a better example because it's clearer wha'ts going on:
square_generator = (i * i for i in range(100000))
for n in iter( square_generator.next, 144):
print n |
|
Date |
User |
Action |
Args |
2011-02-09 20:40:45 | mgrazebrook | set | recipients:
+ mgrazebrook, docs@python |
2011-02-09 20:40:45 | mgrazebrook | set | messageid: <1297284045.4.0.795458647498.issue11163@psf.upfronthosting.co.za> |
2011-02-09 20:40:44 | mgrazebrook | link | issue11163 messages |
2011-02-09 20:40:44 | mgrazebrook | create | |
|