I'm an idiot

Sean 'Shaleh' Perry shalehperry at attbi.com
Fri Jun 28 21:12:41 EDT 2002


> 
> 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