[Tutor] Using read() before closing a file
Eduardo Vieira
eduardo.susan at gmail.com
Tue May 5 18:19:17 CEST 2009
Hello, I found interesting today, as I was playing with this code in the shell:
>>> arq = open('c:/myscripts/simple2.ttt', 'w')
>>> len(a)
9
>>> arq.write('The length is %d' % len(a))
>>> res = arq.read()
>>> print res
The print doesn't print the text I had written, but some thing else I
can't copy and paste to this message. But if I had closed the file and
then did this: res = open('c:/myscripts/simple2.ttt').read(), it would
have worked.
Just thought of sharing this.
Eduardo
More information about the Tutor
mailing list