Python CTypes translation of (pv != NULL)

p.lavarre at ieee.org p.lavarre at ieee.org
Tue Sep 26 15:34:42 EDT 2006


> > > > Q: The C idea of (pv != NULL) ...
> >
> > CTypes tutorial ... == False ... == None ... is None ...
>
> Generally ... 'if pv: ....'  ... should work.
> Except for c_void_p, c_char_p and c_wchar_p instances.

Please can we give me an example of these exceptions?

Indeed those types are the _p types I use most often. Now here
'bool(pv)' and 'if pv' tell me that null is False and non-null is True,
for every kind of null or non-null that I know how to construct.

Is that mapping somehow not reliable across all instances? Or not
cross-platform?

You did mean to say that the Python fragments 'bool(pv)' and 'if pv'
somehow are not accurate translations of the C fragments 'pv != NULL'
and 'if pv'?  Something other kind of Python is?




More information about the Python-list mailing list