Detecting PyCObjects using type()
Frederic Giacometti
frederic.giacometti at arakne.com
Fri May 18 18:35:49 EDT 2001
In effect, one could expect a types.CObjectType element.
Is this a bug or a voluntary feature (on behalf that void* are typeless blah blah
blah...) ?
One could make use of the CObjectType in assert statements, at least, thus I would
'assert' :)) that it is a missing feature (that could be reported as a Python bug
if one ever wants this to be fixed).
FG
Fredrik Lundh wrote:
> Jeff Putsch wrote:
> >
> > What I can not figure out is what "type(PyCObject)" should be, to make the
> > test work. With other types syntax like this works:
> >
> > if type(arg1) == type('')
> >
> > So my question boils down to this: what is the equivalent of "type('')" when
> > using PyCObjects?
>
> get hold of something you know is a PyCObject, and extract
> its type on the module level. here's one way to do it:
>
> import cStringIO
> CObjectType = type(cStringIO.cStringIO_CAPI)
>
> ...
>
> def __init__(self,arg1):
> if not isinstance(arg1, CObjectType):
> raise AnException
>
> ...
>
> Cheers /F
More information about the Python-list
mailing list