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

Finn Bock bckfnn@worldonline.dk
Tue, 13 Mar 2001 20:34:17 GMT


>    GvR> Yes, that was on the list once but got dropped.  You might
>    GvR> want to get together with Finn and Samuele to see what their
>    GvR> rules are.  (They allow the use of some keywords at least as
>    GvR> keyword=expression arguments and as object.attribute names.)

[Barry]

>I'm actually a little surprised that the "Jython vs. CPython"
>differences page doesn't describe this (or am I missing it?):

It is mentioned at the bottom of 

     http://www.jython.org/docs/usejava.html

>    http://www.jython.org/docs/differences.html
>
>I thought it used to.

I have now also added it to the difference page.

>IIRC, keywords were allowed if there was no question of it introducing
>a statement.  So yes, keywords were allowed after the dot in attribute
>lookups, and as keywords in argument lists, but not as variable names
>on the lhs of an assignment (I don't remember if they were legal on
>the rhs, but it seems like that ought to be okay, and is actually
>necessary if you allow them argument lists).

- after "def"
- after a dot "." in trailer
- after "import"
- after "from" (in an import stmt)
- and as keyword argument names in arglist

>It would eliminate much of the need for writing obfuscated code like
>"class_" or "klass".

Not the rules as Jython currently has it. Jython only allows the *use*
of external code which contain reserved words as class, method or
attribute names, including overriding such methods.

The distinction between the Name and AnyName grammar productions have
worked very well for us, but I don't think of it as a general "keywords
can be used as identifiers" feature.

regards,
finn