[C++-sig] Extracting inherited class instances
Johann Borck
johann.borck at densedata.com
Thu Sep 13 11:14:32 CEST 2007
Furkan Kuru wrote:
> Hello,
>
> I have a class exposed to python and extract it like this; ..
>
> int
>
> len=boost::python::len(xList); for(int i=0;i<len;i++) {
>
> boost::python::object cur = xList.pop();
>
> try {
>
> Y& xins = boost::python::extract<Y&> (cur);
>
> YHandler(Y);
>
> }
>
> catch(...) {
>
Is there a reason why you don't use check()?
like
bp::extract<Y&> y (cur);
if (y.check()){ YHandler(y()); }
it at least it reduces the ugliness of the nested structures,
(if needed at all).
Johann
More information about the Cplusplus-sig
mailing list