[python] can I store reference to c++ shared_ptr instance in python list ?
1 Apr
2008
1 Apr
'08
5:03 p.m.
Hi, I'm trying to do this : Python: ptr_list=[] def func(ptr, msg): if "insert"==msg: ptr_list.append(ptr) elif "remove"==msg: ptr_list.remove(ptr) C++: class MyClass{}; int main() { //initialize python exec_file("func.py", global, global); //func.py is the code above object func = global["func"]; shared_ptr<MyClass> mc(new MyClass()); func(mc, "insert"); func(mc, "remove"); } My question is how do I expose my class to python ? I tried class_<MyClass, shared_ptr<MyClass> >("MyClass") but it always fails when I tried to remove an already inserted mc. --------------------------------- You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
6016
Age (days ago)
6016
Last active (days ago)
0 comments
1 participants
participants (1)
-
Kamil Zubair