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

S

Shuaib

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.
 
D

Default User

Shuaib said:
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
 
M

Mark McIntyre

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top