Checking the type of a PyObject

Alex Martelli aleaxit at
Sun Aug 12 21:11:17 CEST 2001

"wim delvaux" <wim.delvaux at> wrote in message
news:3B76B9D2.8EEC8815 at
> Alex Martelli wrote:
> > Hello Wim,
> >
> > > Question remains.  How can I get access to the PyString_Type variable
> > > (buffer) declared in the extension module (if I remember)
> > > for those abstract objects, if you do not know the name of the buffer
> > > but only the name of the type.
> > Incidentally, PyObject_IsInstance(PyObject* obj, PyObject* type)
> > is generally a better way to typecheck than checking for type objects
>     Where does that PyObject_isInstance get the second argument from.  Is
> that again that PyString_Type pointer or somewhere else ?

Yes, it's a PyObject* to the type object, such as PyString_Type -- it's
fetched just the same way any other type object is.


More information about the Python-list mailing list