[C++-sig] V2: isinstance(obj,cls) equivalent

David Abrahams david.abrahams at rcn.com
Fri May 31 22:00:38 CEST 2002


From: "Pearu Peterson" <pearu at cens.ioc.ee>


>
> Hi,
>
> What would be the best way to determine if
>
>   PyObject *obj
>
> is an instance of a Boost.Python V2 wrapped class, say A?

The library does it by checking its metaclass. That is, does

    obj->ob_type->ob_type == boost::python::objects::class_metatype().get()

-Dave






More information about the Cplusplus-sig mailing list