Are Python's reserved words reserved in places they dont need to be?

John Roth JohnRoth1 at jhrothjr.com
Wed Sep 13 10:55:01 EDT 2006


metaperl wrote:
> -->  python -i
> >>> class = "algebra"
>   File "<stdin>", line 1
>     class = "algebra"
>           ^
> SyntaxError: invalid syntax
> >>>
>
>
> Why isn' t the parser smart enough to see that class followed by an
> identifier is used for class definition but class followed by equals is
> a simple assignment?
>
> Also, I had a bug where I tried to set the attributes "user" and "pass"
> in an object but "pass" would not work because it is a reserved word.
> Again pass should be reserved in certain contexts but not others.
>
> Is Python 3k going to fix this sort of thing?

I can give you a categorical NO to that one. Unless
Guido changes his mind, and it's very unlikely, the
answer is in PEP 3099: "Things that will not change
in Python 3000". It says: "The parser won't be more
complex than LL(1)." He does not want to start down
the slippery slope that leads to certain unnamed
languages such as Perl.

John Roth




More information about the Python-list mailing list