Q:

Define array type in Python to be filled by C function

In the C header "param1" is declared as an OUT parameter:
long A_API test( 
                        ___OUT_ char param1
                   )

In the Python code I am trying to use array so that test function has space to fill this parameter.I have imported ctpyes and:
test_array = bytearray(b'')
importArray = (ctypes.c_char*40)(*test_array)

def callTest():
    result = lib.test(importArray)
    return result

But test function doesn't get executed and it fails somewhere. 
Unfortunately I only have .so file and not the source code so I can't debug the code but I assume I have type define issue here.
Any help is appreciated.

A:

Python code should be something that according to function definition:
out_char = ctypes.c_char()
result = lib.test(ctypes.byref(out_char))

