Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pass a value to c++ from python and back?

Tags:

c++

python

i would like to pass values from python to a c++ program for an encryption from inside a python program and then return the value from there to the python program . how to do it?

like image 300
Hick Avatar asked Apr 10 '10 13:04

Hick


1 Answers

If you want to use some existing Unix-style command line utility that reads from stdin and writes to stdout, you can use subprocess.Popen by using Popen.communicate():

import subprocess

p = subprocess.Popen(["/your/app"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
output = p.communicate(input)[0]
like image 99
Georg Fritzsche Avatar answered Oct 04 '22 06:10

Georg Fritzsche