I'm an idiot
David Griswold
david_griswold1 at yahoo.com
Fri Jun 28 21:34:24 EDT 2002
Thanks. I actually figured out the missing parentheses, and the typo on
the split/strip.. I will blame Active Python for being TOO helpful on
the former and a brainfart on the latter.
Now one more thing is happening I can't figure out. When readline gets
to the end of the file (the file is only 34k) it just keeps on reading
blank lines. Am I missing something? I even changed my error I am
checking for to EOFError.
Thanks again.
David
"Sean 'Shaleh' Perry" <shalehperry at attbi.com> wrote in
news:mailman.1025313281.20462.python-list at python.org:
>>
>> f=open('c:\\temp\\temp.txt', 'r')
>> g=open('c:\\temp\\temp1.txt', 'w')
>> while 1:
>> try:
>> s=f.readline
>
> should be 's = f.readline() # I am a method, not a variable'
>
>> g.write(s.split())
>
> split() takes a string and breaks it into pieces, this is not exactly
> what you want, for instance 'this is a line' will beceome ['this',
> 'is', 'a', 'line'].
>
>> except IOError:
>> break
>>
>> g.close
>> f.close
>
> these too should have () on the end.
>
>
>
More information about the Python-list
mailing list