Embedding: how to extend a C++ instance by Python methods

Renzo Tomaselli renzo.tomaselli at tecnotp.it
Thu Jul 4 12:05:52 EDT 2002


Hi all,
    my current goal is to extend a C++ instance behavior by a Python method,
so that an explicit "execute(scriptName, args)" method on such instance will
end up into running a Python method defined by scriptName. Such script
should be entered having "self " as pointing to a C object wrapping the
above instance, so that a number of predefined methods (implemented in C++)
are available from within the script.
While I know how to extend Python by C++ objects, what I miss here is about
binding script execution to the calling C++ object. This is done for the
purpose of avoiding script definers to take care of walking from some
module-level functions down to actual class methods, which is pretty
straightforward to implement.
In short, only method body should be Python; class definition should be C++.
Any help will be appreciated,

Renzo Tomaselli






More information about the Python-list mailing list