file object: seek and close?

Jeff Epler jepler at unpythonic.net
Fri Sep 19 02:35:43 CEST 2003


Well, I didn't have any problems running a similar program.

Here's the program I wrote:
f = open("/tmp/example", "w")
f.write("a\nb\nc\n")
f.close()

f = open("/tmp/example", "r")

for line in f: print line.strip(),
print
f.seek(0)
for lines in f: print line.strip(),

And here's the output:
a b c
a b c





More information about the Python-list mailing list