[Python-Dev] Next-to-last wart in Python syntax.

Finn Bock bckfnn@worldonline.dk
Wed, 14 Mar 2001 11:48:51 GMT


>>>>>> "FB" == Finn Bock <bckfnn@worldonline.dk> writes:
>
>    | - and as keyword argument names in arglist
>
>I think this last one doesn't work:

[Barry]

>-------------------- snip snip --------------------
>Jython 2.0 on java1.3.0 (JIT: jitc)
>Type "copyright", "credits" or "license" for more information.
>>>> def foo(class=None): pass
>Traceback (innermost last):
>  (no code object) at line 0
>  File "<console>", line 1
>	def foo(class=None): pass
>	        ^
>SyntaxError: invalid syntax
>>>> def foo(print=None): pass
>Traceback (innermost last):
>  (no code object) at line 0
>  File "<console>", line 1
>	def foo(print=None): pass
>	        ^
>SyntaxError: invalid syntax
>-------------------- snip snip --------------------

You are trying to use it in the grammer production "varargslist". It
doesn't work there. It only works in the grammer production "arglist".

The distinction is a good example of how jython tries to make it
possible to use reserved words defined in external code, but does not
try to allow the use of reserved words everywhere.

regards,
finn