Super-newbie syntax error question
Charlie Wood
cwood at austin.rr.com
Sun Apr 28 19:07:14 EDT 2002
I have some code that I've cobbled together, and have just introduced a
syntax error. I've read through the docs, done lots of trial and error, and
I'm left scratching my head. Any ideas?
Here's the code:
def endElement(self, name):
if self._parent == "item":
if name == "title":
self._title = self._text
elif name == "link":
self._link = self._text
elif name == "description":
self._descr = self._text
elif name == "category":
self._category = self._text
elif name == "item":
if not self._list_started:
self._out.write("\n")
self._list_started = 1
self._out.write('%s: %s\n%s\n%s\n\n' %
(self._category, self._title, self._descr,
self._link))
f = file("/article.txt", "w")
f.write('Category: %s\nTitle: %s\nDescription: %s\nLink: %s\n\n' %
(self._category, self._title, self._descr, self._link))
f.close()
self._title = None
self._link = None
self._descr = ""
self._category = ""
...and here's the resulting error:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\PYTHON22\lib\rss2html.py", line 46
f = file("/article.txt", "w")
^
SyntaxError: invalid syntax
Your kindness is appreciated.
More information about the Python-list
mailing list