9

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?

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
Hick
  • 35,524
  • 46
  • 151
  • 243

2 Answers2

1

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]
Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
0

As said msw in the other post, the proper solution is using PyObject. If you want to have a two-way communication between C++ & Python, Boost Python would be interesting for you. Take a look at website Boost Python,

This post would also be interesting: How to expose a C++ class to Python without building a module

Community
  • 1
  • 1
Sacha
  • 134
  • 2
  • 12