CXX extension types question

Greg Landrum gReGlAnDrUm at earthlink.net
Sat Apr 28 16:07:50 EDT 2001


I'm working on wrapping a series of C++ classes using CXX.  I'm using a CVS
pull of CXX (because I wanted the updated examples + the VisualC project
files).  In case it makes any difference, I'm using Python2.0 and working
under Win2K.

Things were going swimmingly (CXX is really quite convenient), but I have
run up against a little wall and was hoping someone could tell me how to
climb it.

I've got a single extension module which defines a number of extension types
(PyAtom, PyMol, PyBond, etc.), the problem arises when I want to call
methods of one extension type using arguments of another type.
For example, PyBond has a method FindOtherAtom which takes a PyAtom as an
argument.  I've got:

Py::Object PyBond::FindOtherAtom(const Py::Tuple& args){
  Py::Object o(args[0]);
  // other crap
}

The problem I'm having is converting o (the Py::Object) into a PyAtom (or
using some other method of getting the PyAtom from the args).  I've tried a
number of ways of doing this, but they've pretty much all failed.

Does anyone have any advice on how to handle this?  A pointer to a more
appropriate destination for the question would also be welcomed.

Thanks,
-greg








More information about the Python-list mailing list