[Tutor] Reading from a seperate file
Alan Gauld
alan.gauld at btinternet.com
Fri Oct 26 02:09:25 CEST 2012
On 25/10/12 19:15, myles broomes wrote:
> but according to my program, the seperate file is empty when I know it
> clearly isn't.
OK, So show us the program! Otherwise we are just guessing.
> Python Shell, it does the same thing. I open it in read mode and assign
> to a variable like so:
>
> scoresFile=open('highScores.txt','r')
>
> But whenever I try to say read from it:
>
> scoresFile.read()
>
> It comes up with a blank string:
>
> ' '
How do you get a blank string?
Calling read() without assigning it to a variable means the content of
your file will be lost. But then what are you looking at to say its a
blank string?
We need to see the actual code you are running not just random fragments.
> Can anyone help me?
Sure, but you've got to help us first. Show us your code.
And if you get an error message show us that too - all of it.
And for good measure tell us the Python version and the OS.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list