Python CTypes translation of (pv != NULL)

p.lavarre at ieee.org p.lavarre at ieee.org
Tue Sep 26 15:00:04 EDT 2006


> >Q: The C idea of (pv != NULL) is said most directly in Python ctypes
> >how?
>
> Perhaps reading the ctypes tutorial? (both in the 2.5 docs and in
> <http://starship.python.net/crew/theller/ctypes/tutorial.html>)

Actually, no.  I see three answers or zero, depending on how you like
to count.

Yes that flat edition helps makes this clear, thank you - there I can
more easily grab an ordered list of all matches of text than in the
more prominent shadow:
http://docs.python.org/dev/lib/module-ctypes.html

I see direct discussion only of how to construct null pointers, no
discussion of how to test for them.  Specifically:

The hint { bool(null_ptr) == False } could be read to mean try ==
False, in the "Pointers" text.

The hint { ("values", POINTER(c_int))] ... bar.values = None } could be
read to say try == None, in the "Calling functions" text.

The hint { if item.name is None } could be read to say try is None, in
the "Accessing values exported from dlls" text.

I'm such a Python newbie that I didn't know is None existed alongside
== None.

I guess I'll next dig into that along with the answer below from CTypes
author Thomas Heller.




More information about the Python-list mailing list