0

I want to use python string functions to parse c++ std::string object. I checked the documentation https://docs.python.org/3/extending/extending.html#back-to-the-example , but couldn't find (or understand) all the required details.

For example python function f1 strip and split string using comma,

def f1(str):
    return str.split(str.strip(),',')

Then, how do I call this function in C++ code?

#define PY_SSIZE_T_CLEAN
#include <Python.h>
int main()  {
    std::string str1 = "  A , B , C , D  ";
   // how to pass str1 to python f1() ?
}
ewr3243
  • 397
  • 3
  • 19
  • The link you linked to in your question pertains to calling `C` or `C++` modules from Python. Not the other way around. – druckermanly Oct 28 '19 at 00:38
  • I think you want to look at [this page of the documentation](https://docs.python.org/3/extending/embedding.html) instead. – walnut Oct 28 '19 at 00:39

0 Answers0