| Reply | « Previous Thread | Next Thread » |
|
Hi,
is there any way how to execute the Python module function from char* bufer? Now I'm using the PyImport_Import to load the '.py' module but I would prefer to provide the char* buffer to the interpreter instead. I have found only the PyRun_SimpleString but it does not give me the flexibility of providing the input parameters and checking the result... Thanks a lot, BR STeN |
|
Quote:
Code:
Py_Initialize();
PyObject* module = PyImport_ImportModule("mymodule");
PyObject* func = PyObject_GetAttrString(module, "myfunction");
PyObject* result = PyObject_CallObject(func, NULL);
// Do something with 'result'
Py_DECREF(result);
Py_DECREF(func);
Py_DECREF(module);
Py_Finalize();
If you meant something else, then please clarify. |
|
Hi,
thanks for reply! |But I do not want to import module from file - this is already working for me. The problem is that when I use the PyImport_Import I need to have saved the Python script in the .py file. What I need is to construct the script body dynamically in C++ and provide it to the interpreter as a char* buffer... (of course I can save it to some tepmorary file, but this is not too nice solution). The only method I have found was PyRun_SimpleString - but it does not allow to handle complex scenarios with passing paramateres, readign result, etc. BR STeN |
|
Quote:
Unless you mean you want the Python module to call back into C functions, in which case you need to use a combination of embedding and extending. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| embedding Open C in a SIS file | pzul_wisner | Open C/C++ | 4 | 2008-01-23 20:56 |
| Application embedding in 3rd edition | symbianyucca | General Symbian C++ | 13 | 2007-04-27 05:55 |
| Application Embedding | skumar_rao | General Symbian C++ | 0 | 2007-04-27 05:51 |
| Client/server-framework, embedding, 3rd ed. | tsippa | Symbian User Interface | 4 | 2007-01-26 12:07 |
| Application embedding using Ecom plugin (S60 3rd MR) | akrapacs | Symbian User Interface | 0 | 2006-09-20 17:14 |