Newbie: What's wrong with this 6-line script?

Brent W. Hughes brent.hughes at comcast.net
Thu Jun 3 19:36:36 EDT 2004


If the file Test1.txt contains 257 words, the following script works as
you'd expect.  But if Test1.txt contains 258 words, the last line of the
script prints a blank line instead of the words.
==========================
import sys
f = file("Test1.txt")
s = f.read()
f.close()
t = s.split()
print t
===========================
BTW, if I run these same lines in the Python interactive shell, it will work
fine even with 20000 words in Test1.txt.

Is there something simple I don't understand?

Brent





More information about the Python-list mailing list