Python CTypes translation of (pv != NULL)

p.lavarre at p.lavarre at
Fri Sep 29 01:47:21 CEST 2006

Future Googlers might like this thread to end with the Thomas Heller's
brief conclusive review:

/// Copied 2006-09-28 from

1.2 Check for NULL ctypes pointers

The truth value of any NULL ctypes pointer instance is False.

So, this C code

    if (pv == NULL)
        /* handle NULL pointer */
        /* handle non-NULL pointer */

translates to this Python code

    if not pv:
        # handle NULL pointer
        # handle non-NULL pointer

The above is true for instances of c_void_p, c_char_p, c_wchar_p, and


More information about the Python-list mailing list