[Python-Dev] Lockstep iteration - eureka! (original) (raw)

Finn Bock bckfnn@worldonline.dk
Wed, 09 Aug 2000 19:43:58 GMT


[Skip Montanaro]

Could this be extended to many/most/all current instances of keywords in Python? As Tim pointed out, Fortran has no keywords. It annoys me that I (for example) can't define a method named "print".

[Thomas Wouters]

No. I just (in the trainride from work to home ;) wrote a patch that adds 'from x import y as z' and 'import foo as fee', and came to the conclusion that we can't make 'from' a non-reserved word, for instance. Because if we change

'from' dottedname 'import' NAME* into NAME dottedname 'import' NAME* the parser won't know how to parse other expressions that start with NAME, like 'NAME = expr' or 'NAME is expr'. I know this because I tried it and it didn't work :-) So we can probably make most names that are part of a statement non-reserved words, but not those that uniquely identify a statement. That doesn't leave much words, except perhaps for the 'in' in 'for' -- but 'in' is already a reserved word for other purposes ;)

Just a datapoint.

JPython goes a bit further in its attempt to unreserve reserved words in certain cases:

This allow JPython to do:

from from import x def def(): pass x.exec(from=1, to=2)

This feature was added to ease JPython's integration to existing java libraries. IIRC it was remarked that CPython could also make use of such a feature when integrating to f.ex Tk or COM.

regards, finn