[Tutor] reading output from a c executable.

bob gailer bgailer at gmail.com
Thu Dec 11 19:19:01 CET 2008

Ravi Kondamuru wrote:
> Hi,
> I am writing a script to read list output from a C executable. How 
> should c program be written so that python can read the output as a list?
> Any pointers to info on this appreciated.

Funny that a C programmer is asking for pointers, when C has lots of 
pointers and Python has none. <chuckle>

Python I/O reads strings. So you must encode the list in some manner 
into a string and decode it into a list in the Python program.

Take a look as json. http://www.json.org/

There are links to C and Python. You should be able there to find how to 
encode in C and decode in Python.

You could "roll your own" encoding" but I think json would be easier.

Remember to reply-all so a copy goes to the list.

Bob Gailer
Chapel Hill NC 

More information about the Tutor mailing list