473,802 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing the names of python keywords and functions

Hello,

I am trying to make a program for 3D modelling with "programming".A nd
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!!!

Jun 21 '07 #1
6 1347
I'm not quite clear on what you are asking, but
you can use the __import__() function to import modules by name.

On Jun 21, 3:07 pm, vedrandeko...@v-programs.com wrote:
Hello,

I am trying to make a program for 3D modelling with "programming".A nd
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!!!

Jun 21 '07 #2

moegoldb...@gma il.com je napisao/la:
I'm not quite clear on what you are asking, but
you can use the __import__() function to import modules by name.

I want to invent something like my "programmin g language" like Python
with the same keywords just changed,
for example if user type in my "programmin g language":
>>koristiti os
This line of code my program must write in some file, and my program
(when it run this user file) must read this
line of code like:
>>import os (I just want to change names of keywords)
Jun 21 '07 #3
"<<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??
The keywords are listed in Grammar/Grammar. You need to edit
this file, then recompile.

Regards,
Martin
Jun 21 '07 #4
"Martin v. Löwis" <ma****@v.loewi s.dewrites:
(unattributed author) wrote:
"<<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??

The keywords are listed in Grammar/Grammar. You need to edit
this file, then recompile.
To clarify, are you suggesting changing the source code of the Python
implementation and recompiling it?

If the keywords are changed in the Python executable, won't that break
the import of any Python module written for the standard keywords --
such as many of those in the standard library?

My understanding of the original poster's requirement was that the
keywords should be additional to, not replacement for, the existing
Python keywords.

--
\ "The way to build large Python applications is to componentize |
`\ and loosely-couple the hell out of everything." -- Aahz |
_o__) |
Ben Finney
Jun 22 '07 #5
>>"<<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??
The keywords are listed in Grammar/Grammar. You need to edit
this file, then recompile.

To clarify, are you suggesting changing the source code of the Python
implementation and recompiling it?
Correct.
If the keywords are changed in the Python executable, won't that break
the import of any Python module written for the standard keywords --
such as many of those in the standard library?
Most certainly, yes.
My understanding of the original poster's requirement was that the
keywords should be additional to, not replacement for, the existing
Python keywords.
So he should make them additional in the grammar, too.

It is entirely beyond me *why* the OP wants to do that, but changing
the compiler would be the proper way of implementing that change.

Regards,
Martin
Jun 22 '07 #6
ve***********@v-programs.com schrieb:
Hello,

I am trying to make a program for 3D modelling with "programming".A nd
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/
Jun 22 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
34272
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
49
2880
by: Ville Vainio | last post by:
I don't know if you have seen this before, but here goes: http://text.userlinux.com/white_paper.html There is a jab at Python, though, mentioning that Ruby is more "refined". -- Ville Vainio http://www.students.tut.fi/~vainio24
12
1674
by: Ryan Paul | last post by:
I've spent a lot of time using python, and personally, I feel like it is vastly superior when compared to languages like java, and c++, but there are still a few things that detract from its elegance and flexibility. I thought I might mention a few of them. I'd like to hear what people think of my complaints, and I also like to hear the complaints of others. 1. many keywords (eg:try/except) are strictly imperative, and cannot be used in...
0
2133
by: Veli-Pekka Tätilä | last post by:
Hi, My first post here. I've found some serious accessibility flaws in the Python 2.4 docs and wish they could be rectified over time. I'm very new to Python and initially contacted docs at python org, However, I haven't gotten a reply for a week or so, and figured out I could post here for a larger audience, then. Original message follows: Hello,
0
1787
by: todddeluca | last post by:
I am posting code for calling almost any python function from php, because it seems generally useful. Please feel free to suggest improvements or tell me this has already been done better somewhere else, etc. My limited searching turned up nothing. I work in a heterogeneous environment with php web pages and python modules/scripts. This code requires no no creation of an ad hoc command line interface to the python module and/or ad hoc...
7
2131
by: Petr Jakes | last post by:
I have got names of functions stored in the file. For the simplicity expect one row only with two function names: printFoo, printFOO In my code I would like to define functions and then to read function names from the file, so the functions can be executed in the order the function names are stored in a file. While trying to read the names from the file I am getting always "strings" and I am not able to execute them. I would like to...
16
2612
by: per9000 | last post by:
Hi, I recently started working a lot more in python than I have done in the past. And I discovered something that totally removed the pretty pink clouds of beautifulness that had surrounded my previous python experiences: magic names (I felt almost as sad as when I discovered the strange pink worms that eat you in nethack, not to mention the mind flayers - I really hate them). I guess all programming languages have magic names to some...
6
2502
by: vedrandekovic | last post by:
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!!!!!!!!!!!!!!!!!
7
3392
by: Maximus Decimus | last post by:
HI all, I am using python v2.5 and I am an amateur working on python. I am extending python for my research work and would like some help and guidance w.r.t this matter from you experienced python developers. II want to add some more KEYWORDS and DATATYPES into the python script apart from the existing ones. It would be really great if anybody could guide me as which files and
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10536
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10304
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.