class Row(Structure):
    _fields_ = [('cols_count', c_int), ('cols', POINTER(c_char_p))]

def __init__(self, cols):
    self.cols_count = cols
pc = (c_char_p * cols)()
self.cols = cast(pc, POINTER(c_char_p))


class Unit(Structure):
    _fields_ = [('rows_count', c_int), ('rows', POINTER(Row))]

def __init__(self, rows, cols):
    self.rows_count = rows
pr = (Row * rows)()
Dynamic arrays and structures in structures in python