I am developing a dll that should be used in Python. I have a callback function to send my parameters (defined in a separate header):
typedef int(*call_nBest)(
Do you want something like this?
def callbackU(OutList, ConList, nB):
for i in range(nB):
print("{}\t{}".format(ConList[i], cast(OutList[i], c_char_p)))
return 0
From what I understand you're just trying to match the output of your Python callbackU
function with your C++ MyCallback
function.
Python has a variety of string formatting functionality that can be confusing at first, but pays homage to printf
string formatting.
Since OutList
has type LP_LP_c_char
(pointer to pointer of c_char
, vs "NULL terminated char *
" c_char_p
), we'd best turn it into a native Python data type like so:
def callbackU(OutList, ConList, nB):
for i in range(nB):
out_list_item = cast(OutList[i], c_char_p).value
print("{}\t{}".format(ConList[i], out_list_item))
return 0