473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

embedded function body

Hi,
I need to embed an user-supplied python function body in a C program.
That is, the user has no control over the function definition:

def afunction():
<here goes user code>

Now, the problem is that I can't just append the supplied string,
because I need to properly indent it which isn't trivial - just adding
a tab in front of every line won't do. I'm considering two approaches:
1) write an indent function which is more aware of python syntax;
2) use the python lexxer and work with parse trees.

I've done some experiments with 2). The idea was to parse the following
program:

def afunction():
pass

and the user supplied string (as a complete program) separately, then
replace the <suite> node in the function definition with one including
the statements from the user program.

I've got something that seems to work (but getting
allocation/deallocation right requires some work), but it seems to me
it's a bit awkward. Is the PyNode_* interface public and stable? Is it
ok to use it?

Any advice? Am I missing something? Should I try approach 1)?

TIA,
..TM.

Jul 19 '05 #1
0 911

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

Similar topics

0
by: Pretty woman | last post by:
Hi, I am new to web technologies, including HTML, SVG and javascript. I followed the courses for these languages on www.w3schools.com. I have a question about events raised by a SVG document....
14
by: Alex Molochnikov | last post by:
Is there any way to embed the HTML code inside FRAMESET? Something like this: <frameset cols="50%,*"> <frame src=" ... HTML code for the frame ... "> <frame src="Frame2.html" name="main">...
1
by: Jim Hammond | last post by:
The embedded object gets instantiated once when the page is first loaded and then again every time the button is pressed. The user stays on this page after pressing the button because it is not a...
0
by: RomanVN | last post by:
Hello, I have the following problem. The Windows MediaPlayer object is embedded in an ASP page: --- test.asp --------------------------- <%@ LANGUAGE=VBScript enablesessionstate=true...
2
by: Owen.Leibman | last post by:
Here is a complete web page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html> <head> <title>Javascript Embed and onunload</title> <script type="text/javascript"> function useplayer() {...
0
by: vishnu | last post by:
Hello All, I have embedded python 2.5 in to my C application. As we need the python scripts to run in multi threaded environment I have used Py_NewInterpreter() and Py_EndInterpreter each time I...
4
by: auslandt | last post by:
I have an HTML file that includes a JavaScript. I would like this JavaScript to be able to create an "onChange=<function>" attribute against the password element. Here is an example page of the...
2
Frinavale
by: Frinavale | last post by:
I am attempting to use embedded resources in an Ajax Enabled ASP.NET Web Application. I'm using Visual Studio 2008 and VB.NET server side code. The project is called "EmbeddedResources" with the...
1
by: John Smith | last post by:
I just installed Apache 2.2 and PHP 5.2.6 on an XP machine. I created a test.php file which contains only one function, phpinfo(). It ran fine. I saw the php parameters. I then tested it using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.