Thanks guys.  Here is what I did:

# if the file does not exist:
     f = open('myfile.txt', 'w')
     f.close()
     f = open('myfile.txt', 'r')
# now i can pass it to the ConfigParder:
     cp.readfp(f)

Jeff

Jeff Johnson
[EMAIL PROTECTED]
SanDC, Inc.
623-582-0323
Fax 623-869-0675

Paul McNett wrote:
> Ed Leafe wrote:
> 
>> On Jan 15, 2008, at 3:39 PM, Jeff Johnson wrote:
>>
>>> Thank Ed.  But it IS a file object so I can pass it to:
>>>
>>>       cp = ConfigParser.ConfigParser()
>>>       cp.readfp(f)
>>>
>>> Right?  It appears to work fine.
>>      If you open it for write, it should be a zero-byte file. You would  
>> normally open the file for read (i.e., no parameter) before passing  
>> it to something that needs to read it.
> 
> AFAIK (but test it for yourself at the command line), you either open 
> files read-only or write-only. IOW, if I open a file with 'w', I can 
> write to it but not read from it. I just tried that and got an exception 
> trying to read from it 'bad file descriptor'.
> 
> If you want to open up a file to write to without first erasing its 
> contents, you use 'w+' mode.
> 
> Paul
> 


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]

Reply via email to