iterating over a file with two pointers
Peter Otten
__peter__ at web.de
Wed Sep 18 08:54:42 EDT 2013
nikhil Pandey wrote:
> On Wednesday, September 18, 2013 5:14:10 PM UTC+5:30, Peter Otten wrote:
> I want to iterate in the inner loop by reading each line till some
> condition is met.how can i do that. Thanks for this code.
That's not what I had in mind when I asked you to
>> describe your actual requirement in more detail.
Anyway, change
[...]
>> f, g = tee(f)
>> for inner in islice(g, 3):
>> print " ", inner,
>> break
[...]
to
f, g = tee(f)
for inner in g:
if some condition:
break
print " ", inner,
break
in my example.
More information about the Python-list
mailing list