Reputation: 2293
I have been looking for this solution for some time and cannot find a solution. Some solutions have suggested using the "system" function in the . However, this suggestion is then always followed by 10 people saying never to use system as it lacks thread safety. Does anyone know how to do this?
Just some info: my python script gets and parses JSON from the internet, then creates a textfile, which the c program then uses. So, instead of having to run one, then the other, I want to run them both in succession from the C exe.
EDIT: Grammer
Upvotes: 0
Views: 217
Reputation: 906
You can Use system function in c,c++
like this
system("python ashouri.py");
or
use this code
static PyObject *my_callback = NULL;
static PyObject *
my_set_callback(PyObject *dummy, PyObject *args)
{
PyObject *result = NULL;
PyObject *temp;
if (PyArg_ParseTuple(args, "O:set_callback", &temp)) {
if (!PyCallable_Check(temp)) {
PyErr_SetString(PyExc_TypeError, "parameter must be callable");
return NULL;
}
Py_XINCREF(temp); /* Add a reference to new callback */
Py_XDECREF(my_callback); /* Dispose of previous callback */
my_callback = temp; /* Remember new callback */
/* Boilerplate to return "None" */
Py_INCREF(Py_None);
result = Py_None;
}
return result;
}
Be Successfull
Upvotes: 2