Sorta noob question - file vs. open?

Peter A. Schott paschott at no.yahoo.spamm.com
Tue Aug 23 18:19:16 EDT 2005


Been reading the docs saying that file should replace open in our code, but this
doesn't seem to work:

# Open file for writing, write something, close file
MyFile = file("MyFile.txt", "w")
MyFile.write("This is a test.")
MyFile.close()

However, using:
MyFile = open("MyFile.txt", "w")
MyFile.write("This is a test.")
MyFile.close()

I have no problems.

I'm sure that I'm missing something here about using open vs file, but am not
sure what.  Probably just mis-read something.  If anyone can point me to what I
didn't quite get, I'd appreciate the information.

Thanks.

-Pete



More information about the Python-list mailing list