[C++-sig] Re: instantiating python objects within C++

pj pjdurai at hotmail.com
Fri May 23 23:43:42 CEST 2003

I do not yet know the answer to the first part of your question.

For the second part, after you have instantiated the object,

you might call a method (defined by the user in a python program)


PyObject_CallMethod(ptrToPythonObject, "<method name>", "<printf like format
string>", ...)

Atleast this is how it worked in old C based extension writing.



"Stefan Seefeld" <stefan.seefeld at orthosoft.ca> wrote in message
news:f98cbc39db7a493b8a6b06ee21bceb563ece6c1f at Orthosoft.ca...
> hi there,
> I'v the feeling I'm not seeing the obvious, but...
> ...how can I instantiate a python object in C++ ?
> I'v defined a C++ class, wrapped it into a python
> class, and now want to call a python function
> using an object of that type. Read: I want to
> provide python 'callbacks' that let people interact
> with my C++ application, but in python.
> I'v set up the python interpreter and can run it
> successfully. All I'm missing is a way to instantiate
> objects of said type and inject them into the namespace
> that is passed to the PyRun_File call...
> Thanks a lot,
> Stefan

More information about the Cplusplus-sig mailing list