Pass 'this' to a python script in an extended application

Stou Sandalski stou.sandalski at
Fri Jan 19 01:12:19 CET 2007


I have an application consisting of a main C++ class (and other
classes) stored inside a DLL.  The application uses a small main
executable that links against the main DLL, then initializes and runs
the core class.  The python bindings are inside a .pyd module that also
links against the core DLL file.  I was able to generate the python
bindings against the core class using SWIG.   The application can now
be run either by the bootstrap executable or through the python console

import foo
s = foo.MainClass();

This is awesome, however I want to be able to launch python scripts
from within the application itself (no matter how it was started) and
supply these scripts with a "pointer" to the already initialized main
Class something like:

import foo

s = foo.GetMainClass()

I found this:

but the problem is that I don't know how to "give" the python
interpreter a "pointer" to my class that will be compatible with the
already defined bindings that SWIG generated.  I am trying to keep the
core application dll from knowing about the .pyd extension module.
I apologize if this post belongs in a group dedicated to SWIG. 


More information about the Python-list mailing list