[C++-sig] Possible to inspect type of a boost::python::object
David Abrahams
dave at boost-consulting.com
Tue Sep 12 03:21:22 CEST 2006
"anders langlands" <anderslanglands at gmail.com> writes:
> Currently I'm using extract<T>::check() over a bunch of different types to
> decide what to do with python objects. Is there any way to inspect the type
> directly?
You can inspect the _Python_ type directly:
x.ptr()->ob_type;
or if all the types have a common C++ base class with at least one
virtual function, you can write:
typeid(extract<Base*>(x)())
HTH,
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list