Super-newbie syntax error question

Alex Martelli aleax at aleax.it
Mon Apr 29 03:27:47 EDT 2002


Sean 'Shaleh' Perry wrote:
        ...
>> 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().

No matters, they're interchangeable here in 2.2, and
anyway would never cause a SYNTAX error.  Diagnostics
such as that shown by the OP are invariably caused by
problems on PREVIOUS lines (e.g., unclosed parentheses)
or indentation issues with the current one.


Alex




More information about the Python-list mailing list