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() ?
}
2
  • The link you linked to in your question pertains to calling C or C++ modules from Python. Not the other way around. Commented Oct 28, 2019 at 0:38
  • I think you want to look at this page of the documentation instead. Commented Oct 28, 2019 at 0:39

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.