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

Calling a python script, and getting the returned result in C

Hey!

How do I call a python script from a C programme, and get results from
the python script (which is just a single integer value)?

Thanks.

Aug 16 '06 #1
2 1313
Shuaib wrote:
Hey!

How do I call a python script from a C programme, and get results from
the python script (which is just a single integer value)?
I thought we had a FAQ about this, but I can't seem to come up with it.
At any rate, there's no standard way. If the OS supports it, you can
run the script via the standard system() call, with the command set to
redirect the output to file, then open and read the file from the C
program. How the redirection would be done is implementation-specific.

Otherwise, you're really getting off the standard trail. Things like
popen() can be helpful. You need to find a newsgroup dedicated to your
platform. For UNIX users, comp.unix.programmer is good.


Brian
Aug 16 '06 #2
On 16 Aug 2006 22:18:22 GMT, in comp.lang.c , "Default User"
<de***********@yahoo.comwrote:
>Shuaib wrote:
>Hey!

How do I call a python script from a C programme, and get results from
the python script (which is just a single integer value)?

I thought we had a FAQ about this, but I can't seem to come up with it.
19.30

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Aug 16 '06 #3

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

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
5
by: Ralph Sluiters | last post by:
Hi, i've got a small problem with my python-script. It is a cgi-script, which is called regulary (e.g. every 5 minutes) and returns a xml-data-structure. This script calls a very slow function,...
2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
1
by: robert.differentone | last post by:
Could anybody tell me how to call python modules from C. e.g. my Python module : def add(a,b) return(a+b) How can I call "add.py" from C? Please post any simple example. I have read Python...
3
by: Zeez | last post by:
Hi all, I have a webpage that calls a webservice found on a remote computer. Below is the code of my webpage: ===================================== <html> <head> <script...
5
by: Shuaib | last post by:
Hi! I have a python script which returns an Integer value. How do I call this script from a C programe, and use the result returned? Thanks for your time.
1
by: joeedh | last post by:
Hi I'm getting extremely odd behavior. First of all, why isn't PyEval_EvalCode documented anywhere? Anyway, I'm working on blender's python integration (it embeds python, as opposed to python...
4
by: Alchemist | last post by:
I am using Python 2.4 and Postgresql 8.2 database server. On the database I have created a stored function, example, CREATE OR REPLACE FUNCTION calculateaverage() I created a new python script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.