[Tutor] New to this

Neil Thorman neil.thorman at gmail.com
Sun Jun 20 20:38:20 CEST 2010


I'm picking this up as a hobby really, not having done any programming since
Acorn I'm pretty much starting form scratch (and even back in the BASIC day
I never really got to grips with files).
This is from Alan Gauld's Learning to Program: Handling Files.
http://www.freenetpages.co.uk/hp/alan.gauld/

<http://www.freenetpages.co.uk/hp/alan.gauld/>Can I just check I'm getting
it?


*Menu.txt contains*

*Spam & Eggs*
*Spam & Chips*
*Spam & Spam*

>>>inp = file("menu.txt", "r")
*What is inp? What does it now contain?*
*The following creates a list;*
*
*
*
>>>print inp.readlines()
['spam & eggs\n', 'spam & chips\n', 'spam & spam']

but if I do it again I get:
>>> print inp.readlines()
[]

I'm baffled, why is inp now empty?

Many thanks

Neil

ps. I'm working in the IDLE Python Shell.
*
*
*
*
*
*
*
*
*


This email is confidential and intended for addressee only .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100620/b3f14a26/attachment.html>


More information about the Tutor mailing list