student question

John jlsphar at gmail.com
Fri Jan 7 21:54:29 EST 2011


On Jan 7, 6:47 pm, Corey Richardson <kb1... at aim.com> wrote:
> On 01/07/2011 09:42 PM, John wrote:
>
> >>>> q_file = open(questions_location) #opens the document successfully
> >>>> for line in q_file:
> >            print line
>
> > # prints document successfully
> >>>> line
> > # prints last line of document
> >>>> for line in q_file:
> >            print line # prints nothing
>
> > ...why does it print nothing?
>
> IIRC, iterating through the lines in a file moves the cursor (is that
> the correct term?) to the end of the file. After the first one, use
> q_file.seek(0) to go back to the start. I think.
>
> ~Corey Richardson

fantastic. thanks, corey!



More information about the Python-list mailing list