[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_
6226
Age (days ago)
6226
Last active (days ago)
0 comments
1 participants
participants (1)
-
Kamil Zubair