[C++-sig] Re: extracting C++ objects

James Mastro jmastro at rochester.rr.com
Mon Jul 19 05:54:23 CEST 2004


At 10:28 PM 7/18/2004, you wrote:
>1. Did you wrap MyPoint with class_<MyPoint> and has the extension
>    module that does that wrapping been loaded at this point?

This is the code for the C++ class and the wrapping. I took out everything 
but a constructor, but I have the same problems. It's loaded because the 
Python object is using it right before I try to extract the object.

class MyPoint    {
     public:
         MyPoint() {}
};

BOOST_PYTHON_MODULE(JimsModule)
{
     class_<MyPoint>("MyPoint", init<>())
     ;
}


>2. Does it work if you do it in two steps?
>
>    object pt = obj.attr("location");
>    MyPoint& myPt = extract<MyPoint&>(pt);

Nope...same result.

Thanks for your comments in the last email. 100 times simpler and cleaner 
now, and no I didn't need PyImport_AddModule in there. I'll put together a 
example of this problem and post it.

-jim 




More information about the Cplusplus-sig mailing list