[C++-sig] C++ derived from bp::dict
Hi,
Being a newbie to boost::python, I have a question ( hopefully
simple), which failed to find the answer in mail logs:
let's say
a. I have a C++ class, derived from boost::python::dict ;
b. I would like later to get access to myLong, and to the dictionary,
my class derived from.
Would mentioning the boost::python::dict as a base wtihin wrapping
section be enough to get access to dictionary?
(Something like...
"
class myd :boost::python::dict {
...
public:
unsigned long myLong;
}
BOOST_PYTHON_MODULE(mymod)
{
using namespace boost::python;
class_ > ("mydict")
.def_readwrite("pd", &myd::pd);
...
}
Thanks.
Michael.
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] C++ derived from bp::dict
Hi Michael, I strongly doubt that what you want is possible. While class_ generates a Python type that wraps 'A', boost::python::dict itself is not built that way. Rather, it is a proxy to a Python dict object. Types defined via "class_<>" are added to a type registrar, which is inspected whenever a C++<->Python conversion is requested. I strongly doubt that the boost::python::object derivatives are themselves registered there. Besides, Python has strong requirements concerning what types are allowed to derive from what base types (as far as the associated meta-classes are concerned), which I don't think are met by the above. Stefan -- ...ich hab' noch einen Koffer in Berlin... ___ Cplusplus-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] C++ derived from bp::dict
Thanks for a speedy reply! Michael. ___ Cplusplus-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/cplusplus-sig
