Reading/writing files

Brian Quinlan brian at sweetapp.com
Mon Apr 14 13:53:20 EDT 2003


> for line in a file
> 	print line
> print done

Close:

# file is a really bad name for a variable!
for line in file:
    print line
print 'done'

> and for writing, I've tried doing file.write(blah) (blah is a list),
but
> it wont write.

How do you want the list represented in the file? One element per line?

Cheers,
Brian






More information about the Python-list mailing list