Jul-07-2018, 05:04 AM
I'm working on embedding python 3.6 into a C++ application.
To get the hang of how all this works I'm writing a function that simply posts a message to the debug log (as well as on screen). I've successfully exposed the function to python.
My bindings look like this:
To get the hang of how all this works I'm writing a function that simply posts a message to the debug log (as well as on screen). I've successfully exposed the function to python.
import test test.debug("This is a debug Message")The above will successfully call the function...however I can't seem to figure out how to get the argument back from python
My bindings look like this:
//Bindings to allow Python scripts to post Log infos static PyObject* DebugInfo(PyObject *self, PyObject *args) { std::string message = <MAGIC SHOULD HAPPEN HERE>; LOGINFO(message.c_str()); return 0; } static PyMethodDef DebugInfo_Method[] = { { "Debug_Info", DebugInfo, METH_VARARGS, "Post message as Debug Info" }, { NULL, NULL, 0, NULL } }; //End of Log Infos Binding //Define Python Modue and link to bindings static PyModuleDef test = { PyModuleDef_HEAD_INIT, "DebugInfo", NULL, -1, DebugInfo_Method, NULL, NULL, NULL, NULL }; static PyObject* PyInit_test(void) { return PyModule_Create(&test); };I may have done this completely wrong, I'm extremely new to working with python and c++.