Re: [C++-sig] Executing python code from C++

2010-02-07 Thread Stefan Seefeld
On 02/07/2010 04:51 PM, Murray Cumming wrote: On Sun, 2010-02-07 at 09:51 -0500, Stefan Seefeld wrote: Sorry, I don't understand the question. Can you give an example of what you want to do ? May be you want to "exec" some python code that defines a function, which you then want to extract a

Re: [C++-sig] Executing python code from C++

2010-02-07 Thread Murray Cumming
On Sun, 2010-02-07 at 09:51 -0500, Stefan Seefeld wrote: > > Sorry, I don't understand the question. Can you give an example of > what > you want to do ? May be you want to "exec" some python code that > defines > a function, which you then want to extract and call later ? > That may look like t

Re: [C++-sig] Executing python code from C++

2010-02-07 Thread Stefan Seefeld
On 02/07/2010 08:29 AM, Murray Cumming wrote: So, I guess I can use boost::python::exec() to call code that defines a Python function. bpl::exec() executes a chunk of Python code, no matter what it contains. But how can I get a boost::python::object for the (callable object of) the functi

Re: [C++-sig] Executing python code from C++

2010-02-07 Thread Murray Cumming
On Sun, 2010-02-07 at 08:03 -0500, Stefan Seefeld wrote: > On 02/07/2010 05:22 AM, Murray Cumming wrote: > > In Glom, to execute arbitrary Python code, I use PyRun_String() to parse > > the Python code, PyDict_GetItemString() and PyObject_Call() to get a > > callable object for that code, and then

Re: [C++-sig] Executing python code from C++

2010-02-07 Thread Stefan Seefeld
On 02/07/2010 05:22 AM, Murray Cumming wrote: In Glom, to execute arbitrary Python code, I use PyRun_String() to parse the Python code, PyDict_GetItemString() and PyObject_Call() to get a callable object for that code, and then PyObject_CallObject() to actually execute the code and get a return v

[C++-sig] Executing python code from C++

2010-02-07 Thread Murray Cumming
In Glom, to execute arbitrary Python code, I use PyRun_String() to parse the Python code, PyDict_GetItemString() and PyObject_Call() to get a callable object for that code, and then PyObject_CallObject() to actually execute the code and get a return value. This was the result of experimentation and