473,322 Members | 1,703 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,322 software developers and data experts.

How can I rewrite the JPython to Python?

Hello!I am new to Python and I would like to rewrite the following code to
python use to call by C program:// JPython code
=======================================
import org.python.util.PythonInterpreter;
import org.python.core.*;

public class SimpleEmbedded {
public static void main(String []args)
throws PyException
{
PythonInterpreter interp =
new PythonInterpreter();

System.out.println("Hello, brave new world");
interp.exec("import sys");
interp.exec("print sys");

interp.set("a", new PyInteger(42));
interp.exec("print a");
interp.exec("x = 2+2");
PyObject x = interp.get("x");

System.out.println("x: "+x);
System.out.println("Goodbye, cruel world");
}
}
// C Language code ==============================
void main() {
Py_Initialize();
printf("Hello, brave new world");

PyRun_SimpleString("import sys"); PyRun_SimpleString("print sys");
// interp.set("a", new PyInteger(42));
// I can't rewrite,Please Help!

PyRun_SimpleString("print a"); PyRun_SimpleString("x = 2+2");
// PyObject x = interp.get("x");
// I can't rewrite,Please Help!
// System.out.println("x: "+x);

// I can't rewrite,Please Help!
Py_Finalize();
printf("Goodbye, cruel world");
}

Jul 18 '05 #1
0 1512

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

Similar topics

4
by: John Abel | last post by:
OK, I'm guessing what I was after ( see below ) isn't possible. Does anyone know of an easy way of having verify_request inform the request handler of certain events, say client is unauthorised? ...
1
by: darrel | last post by:
We're using URL rewriting (Isapi Rewrite). Is there any way to grab the pre-rewritten URL or can you only grab the rewritten one? I'm assuming you can't (as that's sort of the point of URL...
1
by: baroque Chou | last post by:
Thanks for the help available on msdn, I have succesful done the rewrite job. But there are 2 problems arise: 1.when I try to rewrite the url from say: www.yoursite.com/beverages.aspx to...
14
by: Stan Canepa | last post by:
This post is mostly for discussion. Why rewrite in .NET? Just a general discussion not related to any specific details. I was just looking to see what reasons developers are looking to, to help...
3
by: sandip desale | last post by:
Dear All, I have a python dictionary file. I want to create a map of that dictionary and want to use the same in my Java Program. Can anybody please tell me how to use the same python dictionary...
0
by: Ron Adam | last post by:
If anyone is interested in participating in discussing the details of the PyDoc rewrite/refactoring I've been working on, a discussion is being started on the doc-sig list. Doc-Sig@python.org ...
5
by: Johnny Blonde | last post by:
Hello Group! I really tried hard for two hours to rewrite the following expression (python 2.4): -------------------------- teilnehmer = for r in Reisen.select(AND(Reisen.q.RESVON <= datum,...
6
by: Siegfried Heintze | last post by:
I love the typing assist I get when using C# in VS2005 to write COM clients. I need to write a program to automate some tasks in outlook. Givin that the typing assist feature is very important to...
1
by: mazdotnet | last post by:
Hi all, I've installed the new Microsoft URL Rewrite Module for IIS 7.0 http://www.iis.net/downloads/default.aspx?tabid=34&i=1691&g=6 on both my laptop (Vista Home Premium) and my desktop...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.