Python CTypes translation of (pv != NULL)

p.lavarre at ieee.org p.lavarre at ieee.org
Mon Sep 25 20:27:08 EDT 2006


Q: The C idea of (pv != NULL) is said most directly in Python ctypes
how?

A: We are of course supposed to write something like:

        def c_not_null(pv):
                return (ctypes.cast(pv, ctypes.c_void_p).value != None)

Yes?

Working from the doc, me the clueless newbie, I was slow to guess such
relevant truths as:

ctypes.c_void_p(0).value == None
ctypes.c_void_p(0) != ctypes.c_void_p(0)

Curiously yours, thanks in advance, Pat LaVarre




More information about the Python-list mailing list