Changing the names of python keywords and functions

Stargaming stargaming at gmail.com
Fri Jun 22 11:39:06 EDT 2007


vedrandekovic at v-programs.com schrieb:
> Hello,
> 
> I am trying to make a program for 3D modelling with "programming".And
> I want make my own program commands,
> 
> for example when user type code in my program:
> 
> "<<koristiti>> OS"- (THIS IS MY IMAGINARY EXAMPLE OF KEYWORD),
> 
> my program must write this code in some user file, but my
> 
> program must read this command like: "import os".How
> 
> can I do something like that??
> 
>                            Please, HELP ME somebody!!!
> 

Besides your request is sorta weird (languages are mostly meant to give 
a ruleset of expressions, not a framework of mutability, at least the 
more widespread ones), Python does not support something like this out 
of the box. There have been several discussions about such features and 
they were all abandoned due to unification.

You can, of course, follow the "normal" track to implement any language 
and write a parser, lexer, compiler and whatever. Tools like 
`pyparsing`_ or `PLY`_ might help you (there are much more).
Though, there *is* a mutable codeset of Python called `Logix`_. As far 
as I glanced at it, it is pretty mutable and might fit your needs perfectly.

Ah, and if you perhaps remove the leading << there, this might be pretty 
much implementable by overloading __rshift__ at your koristiti object.

HTH,
Stargaming

.. _pyparsing: http://pyparsing.wikispaces.com/
.. _PLY: http://www.dabeaz.com/ply/ply.html
.. _Logix: http://livelogix.net/logix/



More information about the Python-list mailing list