Sorta noob question - file vs. open?



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
.



Relevant Pages

  • Re: This group
    ... > I thought it might be about writing and stuff, but after reading the ... Prev by Date: ...
    (misc.writing)
  • Re: This group
    ... >> I thought it might be about writing and stuff, but after reading the ... >> last few days of posts, it just seems to be a confused mishmash of ... Prev by Date: ...
    (misc.writing)
  • Re: Newbie: Array of pointers to strings questions.
    ... CBFalconer wrote: ... > I like to think it is an error I would never make in writing it. ... > Yet it is surprisingly elusive when reading other peoples code. ... Prev by Date: ...
    (comp.lang.c)
  • Re: Windows IT Pro Magazine
    ... sorry this is MCSE's...we don't do reading or ... writing. ... reply not influenced by ether reason, ... Prev by Date: ...
    (microsoft.public.cert.exam.mcse)
  • Re: ATTN: Sir Tony
    ... AndrewR secured a place in history by writing: ... > As I haven't been reading the group that closely for the past year ... Prev by Date: ...
    (uk.rec.motorcycles)

Loading