Re[2]: [Tutor] write to a file

python python <python@inkedmn.net>
Mon, 19 Aug 2002 14:55:17 -0700


Just FYI,

in python 2.2, the "open" method for opening a file has been replaced
with "file", like this:

openfile = file("c:\somefile.htm", 'w')

brett

RP> On Mon, Aug 19, 2002 at 05:34:20PM -0400, Gus Tabares wrote:
>> Hello,
>>       
>>       I'm trying write something to a file but I keep on getting this error:
>> 
>> Traceback (most recent call last):
>>   File "test.py", line 9, in ?
>>     os.open("C:\blah.txt", 'w')
>> TypeError: an integer is required
>> 
>>       I don't see what an integer has to do with anything? Thanks in advance...

RP> Forget the 'os.' just use open("C:blah.txt",'w').

RP> os.open() returns a file *descriptor* and is different from the builtin
RP> open() which returns a file *object* and takes different parameters.