Are Python's reserved words reserved in places they dont need to be?
steve at holdenweb.com
Wed Sep 13 02:20:36 CEST 2006
> Istvan Albert wrote:
>>>--> python -i
>>>>>>class = "algebra"
>>> File "<stdin>", line 1
>>> class = "algebra"
>>>SyntaxError: invalid syntax
>>Designing a syntax to avoid all possible newbie errors is impractical
>>because as soon as you are finished with one iteration the new newbies
>>will start making different kinds of errors...
>>Take solace in the fact that you've been immediately notifed of the
>>error while its fix: renaming pass to passwd is trivial ...
> The error message is not very explicit - "class is a reserved word"
> will make far more sense to a new programmer than SyntaxError.
> Especially since the expression is rather innocent looking and
Well maybe, but one might as well have the interpreter complain that
'"=" is an invalid class name'. Once an unmatchable token is encountered
which parsing it's often difficult from inside the parser to determine
exactly what the programmer's intent was.
Otherwise you could try and fix the error, like the PL/1 F-level
compiler used to. This would usually work when all that was wrong was a
missing semicolon, but it frequently went completely berserk in other
cases, leading to strange and implausible error reports.
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list