[C++-sig] test if object instance is instance of extension class in C++

Holger Joukl Holger.Joukl at LBBW.de
Thu Feb 23 17:50:49 CET 2012


what's the recommended way to check if an object instance is an instance of
my extension class
in C++ code?

I'm currently doing a very ugly

#define isMyExtensionClass(pyobj) (strcmp(pyobj->ob_type->tp_name,
"MyExtensionClass") == 0)

on PyObj* pyobj.

I bet there is a better way but just can't seem to find it.


Landesbank Baden-Wuerttemberg
Anstalt des oeffentlichen Rechts
Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz
HRA 12704
Amtsgericht Stuttgart

More information about the Cplusplus-sig mailing list