Is 'x' an instance of a new-style class?
gagsl-py2 at yahoo.com.ar
Tue Sep 16 11:38:33 CEST 2008
En Tue, 16 Sep 2008 05:26:14 -0300, MatthewS <schaefer.mp at gmail.com>
> I've seen the question raised several times here, but apparently never
> answered. Since PyInstance_Check returns False for new-style class
> instances, is there a standard procedure for testing this using the C-
> I would greatly appreciate some help with this.
In Python you would write isinstance(x, object). In C, "object" is
PyBaseObject_Type, and a direct translation would be
PyObject_IsInstance(x, PyBaseObject_Type), or perhaps
PyObject_TypeCheck(x, &PyBaseObject_Type) (to mimic how other PyXXX_Check
are implemented, and probably faster)
More information about the Python-list