student question

Peter Pearson ppearson at nowhere.invalid
Sat Jan 8 13:33:28 EST 2011


On Fri, 7 Jan 2011 18:42:45 -0800 (PST), John <jlsphar at gmail.com> 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?

open(filename) returns an iterator, not a list.  Once you
have exhausted the iterator, it stays exhausted.


-- 
To email me, substitute nowhere->spamcop, invalid->net.



More information about the Python-list mailing list