Re: Sorta noob question - file vs. open?

2005-08-24 Thread Peter A.Schott
I'll have to try this again. I obviously did something wrong in my code. I was getting errors about not being able to write a string because it wasn't supported. It was driving me nuts for a while until I just gave up and went back to open(). I'll do some more playing and if I continue to get

Re: Sorta noob question - file vs. open?

2005-08-24 Thread Peter Hansen
Peter A. Schott wrote: Thanks to all who replied. If open is still preferred, I will stick with that. FWIW, that's not an unqualified preferred. To demonstrate by example, neither of the above is considered preferred, though they both work: outputFile = file('path.to.file') if

Re: Sorta noob question - file vs. open?

2005-08-24 Thread Scott David Daniels
Peter A. Schott wrote: I'll have to try this again. I obviously did something wrong in my code. I was getting errors about not being able to write a string because it wasn't supported. It was driving me nuts for a while until I just gave up and went back to open(). I expect somewhere

Sorta noob question - file vs. open?

2005-08-23 Thread Peter A.Schott
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

Re: Sorta noob question - file vs. open?

2005-08-23 Thread Scott David Daniels
Peter A. Schott wrote: Been reading the docs saying that file should replace open in our code, but this doesn't seem to work: This was really a misstatement; open is still preferred. file is now a built in class, and its constructor is the same as open. I think the current docs have been

Re: Sorta noob question - file vs. open?

2005-08-23 Thread Russell E. Owen
In article [EMAIL PROTECTED], Peter A. Schott [EMAIL PROTECTED] wrote: 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.)

Re: Sorta noob question - file vs. open?

2005-08-23 Thread Jason Drew
Both your code snippets above work should work OK. If it seems like a file isn't being written, maybe you should specify its full path so you are sure about where to check for it. On the file-or-open question, the Python docs state, The intent is for open() to continue to be preferred for use as

Re: Sorta noob question - file vs. open?

2005-08-23 Thread Steve Holden
Peter A.Schott wrote: 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 =

Re: Sorta noob question - file vs. open?

2005-08-23 Thread Fredrik Lundh
Peter A.Schott wrote: Been reading the docs saying that file should replace open in our code, but this doesn't seem to work: what docs? open is the preferred way to open a file. file is a type constructor. in contemporary python, they happen to map to the same callable, but that's not