Boost logo

Boost Users :

From: Kamil Zubair (kamilzubair_at_[hidden])
Date: 2008-04-01 13:03:29


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.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net