Python newbie with a problem writing files

John Jones j4jones at ptd.net
Sun Sep 3 20:57:40 EDT 2006


Hi All,

    I have been driven insane by this error. I have this small program, shown below, which runs great until it gets to writing the data out to the file. I am running an install of Python 2.4. Yes, feedparser is functioning fine (I put in print feed_title statements as tests - but have since removed them). I am missing something obvious.

Thanks
JJ 

Code: 

import feedparser
from xml.sax import saxutils

feed_number=200

feed_list = open("feed_listing.conf","r")
for each_feed in feed_list:
    data=feedparser.parse(each_feed)
    feed_title=data.entries[0].title
    xml_output=open("xml_data\\feed" + str(feed_number) + ".xml", "w")
    xml_output.write = (feed_title)
    xml_output.close()
    feed_number+=1

Error Message:

Traceback (most recent call last):
  File "C:/My_Blogroll/JJ_Blogroll2", line 11, in ?
    xml_output.write = (feed_title)
AttributeError: 'file' object attribute 'write' is read-only




More information about the Python-list mailing list