Super-newbie syntax error question

Sean 'Shaleh' Perry shalehperry at attbi.com
Sun Apr 28 21:53:58 EDT 2002


> 
>     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
> 

Should be:

f = open() not file().





More information about the Python-list mailing list