[C++-sig] extract

Roman Yakovenko roman.yakovenko at gmail.com
Sat Jun 2 11:41:36 CEST 2007


On 6/1/07, Sean Ross-Ross <srossross at gmail.com> wrote:
> hi,
> How do I write multiple to_python conversions?
> Say I have an boost::python::object and I call extract<somthing>,
> where  the object could be a "c++ somthing class" or a Python dictionary

I guess you should read "extract" documentation:
http://boost.org/libs/python/doc/v2/extract.html

boost::python::extract< something > ex( obj );
if( ex.check() ){
    ....
}
else{
    ....
}


I didn't try this for boost::python::dict class. If this will not
work, you can always use "isinstance" functionality.
-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list