[Tutor] c++ on python

Alan Gauld alan.gauld at btinternet.com
Wed Mar 12 10:11:03 CET 2014


On 11/03/14 14:27, Gabriele Brambilla wrote:

>     Is it a library or a program?
>
> A program. it should use only standard C++ libraries.

OK, If it's a program, that is, it compiles into an
executable that you can run then you can run it from
within Python using the subprocess module.

Do you know how you interact with it?
Can you give it start up arguments?
Does it read from stdin?
Does it write to stdout?
Does it read a data file?
Does it write a file out?

You will need to know that to be able to use the
program from inside Python.

> What do you mean about using Python to work with it?
 > How do you usually do?

I mean running the C++ program and exchanging data
with it. That's what subprocess allows you to do.

If it were a library then you would have to call
the individual C++ functions directly using
something like ctypes, which is usually more
complex.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list