Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-02-13 18:56:45

----- Original Message -----
From: "Dominic Sacré" <bugcreator_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, February 13, 2002 6:26 PM
Subject: [boost] Boost.Python: Get a pointer to my C++ class from a

> I have a C++ class A, which is exported to Python. In Python, I define
> another class B, which is derived from A. I then create an object of class
> in Python, and on the C++ side I obtain a PyObject* to that object.
> What I need now is a way to get a pointer to the underlying object of
class A
> from that PyObject*, but I can't figure out how...
> I guess this question sounds simple, and maybe there's an obvious answer,
> I've spent several hours trying to find a solution for my problem, to no
> avail...
> Thanks in advance,
> Dominic

fortunately, it /is/ simple:

A* get_A(PyObject* p) { return from_python(p, boost::python::type<A*>()); }


Boost list run by bdawes at, gregod at, cpdaniel at, john at