Python changing keywords name

James Stroud jstroud at mbi.ucla.edu
Sat Jun 23 17:45:00 EDT 2007


vedrandekovic at v-programs.com wrote:
> Hello AGAIN,
> 
> I  on working on windows and Python 2.4. Where can I find and CHANGE
> python
> grammar.  ( I just want to change the keywords )
> 
>                                                       PLEASE HELP ME
> SOMEBODY!!!!!!
>  
> THANKS!!!!!!!!!!!!!!!!!
> 

1. Download the source to python
2. Unpack the source
3. Change to the "Grammar" directory
5. Edit the "Grammar" file appropriately
6. Compile python
7. Your interpreter now has new keywords
8. Use at your own risk.

For example, I changed a print statent in this file from

print_stmt: 'print' ( [ test (',' test)* [','] ] |
                       '>>' test [ (',' test)+ [','] ] )

to

print_stmt: 'splodnik' ( [ test (',' test)* [','] ] |
                       '>>' test [ (',' test)+ [','] ] )

And here are the results:

   Python 2.5 (r25:51908, Jun 23 2007, 14:42:05)
   [GCC 4.1.1] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>> splodnik 'This is a splodnik statement.'
   This is a splodnik statement.

You will also want to change every instance of the word "print" in every 
.py file to "splodnik" in the pythonsource before building, so that you 
won't break your standard lib. Also, no one else on the planet will be 
using this version of python, so you will not be able to use any one 
else's python code unless you replace keywords in their python source.

Now that you know how to do this, please don't ask again.

James



More information about the Python-list mailing list