[C++-sig] Extracting inherited class instances

Furkan Kuru furkankuru at gmail.com
Thu Sep 13 13:16:58 CEST 2007


yes, thanks
check will solve my problem.


On 9/12/07, Johann Borck <johann.borck at densedata.com> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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&> x (cur);
>       if (x.check()){ YHandler(x()); }
>
> it at least seems to reduce the ugliness of the nested structure.
>
> Johann
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFG59KRTaz+euYGsRERAsojAKCLrL6EEqXUPYe7BH3dR0zeWJFJYACfQND1
> vOzP8qvGTWSZU5HEbSYP4s8=
> =d5Rx
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>



-- 
Furkan Kuru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070913/f230097e/attachment.htm>


More information about the Cplusplus-sig mailing list