On Tue, 2009-06-30 at 13:24 -0700, Beni Cherniavsky wrote:
> On Jun 24, 11:40 pm, "J. Cliff Dyer" <j...@sdf.lonestar.org> wrote:
> > Also note that you can iterate over a file several times:
> >
> > f = open('foo.txt')
> > for line in f:
> >     print line[0]  # prints the first character of every line
> > for line in f:
> >     print line[1]  #prints the second character of every line
> >
> No, you can't.  The second loop prints nothing!
> A file by default advances forward.  Once you reach the end, you stay
> there.

You are, of course, absolutely right.  Sorry for the misinformation.

:(

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to