Calling C programs

Bjoern Paschen paschen at mavd.de
Thu Mar 4 06:21:49 EST 2004


C GIllespie wrote:
> I have a simple C program which outputs a string. I want to be able to
> call this progam from python and assign the output to a variable. What's
> the best way to do this?
> I've tried
> os.system('/tmp/hello')
> os.execv('/tmp/hello',[' '])
> but I can't seem to store the return value.

One possible way is to use os.popen().
http://www.python.org/doc/current/lib/os-newstreams.html

Bjoern



More information about the Python-list mailing list