import ctypes

...

def varchar(n):
    '''allocate a structure for a VARCHAR(n)'''

    class Varchar(ctypes.Structure):
        '''a structure to accommodate a VARCHAR(n)'''

        _fields_ = [
            ('length',ctypes.c_ushort),
            ('value',ctypes.c_char * n) ]

    return Varchar()

...

firstname = varchar(25)
surname = varchar(25)
description = varchar(2000)

# use the Varchar() instances as data buffers
import pyngres as py
datavalues = (py.IIAPI_DATAVALUE * 3)()
datavalues[0].dv_value = ctypes.addressof(firstname)
datavalues[1].dv_value = ctypes.addressof(surname)
datavalues[2].dv_value = ctypes.addressof(description)

...
