Can python control complicated classes/objects written in C++
Bo Peng
bpeng at rice.edu
Sat Jun 5 00:24:38 EDT 2004
Dear Python group:
I am planning on an application that involves several complicated C++
classes. Basically, there will be one or two big data objects and some
"action" objects that can act on the data. I would like to use a script
language to control the interaction between these c++ objects.
I become interested in Python since it can load C++ objects and can even
extend C++ classes. However, I am not quite sure to what extent can
python do this. Ideally, I would like to have something like
(pseudo code, not in python)
> data = new TData( option1=..., option2=...)
> action1 = new TAction(option1=range(1,10)...)
> action2 = new TSubAction(option1=sin(5),..., option2=...)
> data.run( action1, action2)
> data.print
The benefits here is that I do not have to worry about user-input
(python handles functions like range(), and numeric/string operations
for me and send them to my objects), running logic (user create the
scripts) and need only focus on the objects themselves. It would be
better if users can easily extend TAction by themselves, through either
Python or C++.
I am totally new to Python. I have read boost.python, python extension
document but still do not know exactly what to do. My questions are:
1. can Python fully read/write member data and run member functions of
my objects?
2. can python pass complicated objects (TAction) to another object (TData)?
3. If python can not do this, I will have to create my own scripting
language. Given the above pseudo code, any suggestion on how to
implement it? I have googgled Qt Script for Application and many other
weird implementations but I either do not like the grammar of the script
language or the huge overheads.
Many thanks in advance.
Bo
More information about the Python-list
mailing list