0

I would like to call a python function through a c++ script. I know how to call a c++ function in a python code but no the other way. for example, I would like to use the return value of this python function in a c++ script like this:

import pandas as pd
def concat(x1,x2):
a = pd.DataFrame(pd.concat([pd.DataFrame(x1), pd.DataFrame(x2)], axis=1))
return a
#
void Foot::update(){
ccerr << "Merge " << PLate->me->vertIncl << endl;
con[a] = concat(model->getA(),model->getB())}

Is it possible?

  • You will have to use system to run the python file and then parse the output. Will be good for scripts. But calling a function of the script not sure about that. – Kishan Kumar Nov 02 '17 at 10:41
  • What about RFC or pipe/socket remote calls? – Smit Ycyken Nov 02 '17 at 10:41
  • https://stackoverflow.com/questions/49137/calling-python-from-a-c-program-for-distribution have a look here – Kishan Kumar Nov 02 '17 at 10:44
  • I read it before Kishan Kumar, but i didn't find my answer, because what i really want is the return value of the python function. thank you for the answer – Jenny Rolande Nov 02 '17 at 10:46
  • @JennyRolande: This (answer](https://stackoverflow.com/a/328451/3545273) in the proposed duplicate contains all what you need. You have to embed (or link) both the Python interpretor **and** the pandas library in your C++ program. – Serge Ballesta Nov 02 '17 at 10:53
  • @SergeBallesta ah ok. thank you so much. I will try it immediately – Jenny Rolande Nov 02 '17 at 10:57

0 Answers0