file object: seek and close?

Jeff Epler jepler at unpythonic.net
Thu Sep 18 20:35:43 EDT 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