[Tutor] string assignment

Magnus Lycka magnus@thinkware.se
Thu Nov 14 19:34:01 2002


At 15:58 2002-11-14 -0800, Sean 'Shaleh' Perry wrote:
>On Wednesday 13 November 2002 07:13, Carla Attianese wrote:
> > SyntaxError: invalid syntax
> >   File "C:\Documents and Settings\carla\a.py", line 258
> >     CREATE_STATEMENT_TABLE="""
> >                          ^
>
>this most likely means the error is on the line before this one.

This is such a common flaw in compiler error
messages, in all programming languages I've run
into that seasoned programmers feel that it's
quite natural with this kind of diagnostics.

In a way it is. The mistake that was probably done
on the preceding line was syntactically correct,
but only if the line Python complains about looked
different. It's not until we reach this line that
we can conclude that there is a syntax error.

The error message could still be much more user
friendly though. E.g.

 >>> a = (123,
... 123,
... 123
... c = a
Traceback (  File "<interactive input>", line 4
     c = a
     ^
SyntaxError: invalid syntax

should rather give

SyntaxError: missing , or )

or something like that.

Will PyChecker do more for such a bug?
(Sourceforge is down, otherwise I'd check myself.)


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se