title: Python ctypes pointer to pointer to structure
body: <p>I'm having problems getting a pointer to a pointer to a structure working. This is the code I have which throws the exception "ArgumentError: argument 1: :  expected LP_LP_List instance instead of pointer to LP_LP_List".</p>
  
  <pre><code>class List(Structure):
      _fields_ = (
          ('head', POINTER(Node)),
          ('tail', POINTER(Node)),
          ('current', POINTER(Node)),
          ('saved', POINTER(Node)),
          ('infosize', c_int),
          ('listsize', c_ulong),
          ('current_index', c_ulong),
          ('save_index', c_ulong),
          ('modified', c_bool),
          ('search_origin', c_int),
          ('search_dir', c_int),
          )
  
  list_p = POINTER(List)
  
  create = lib.DLL_CreateList
  create.argtypes = [POINTER(POINTER(List)),]
  create.restype = POINTER(List)
  mem = POINTER(list_p)()
  retval = create(byref(mem))
  </code></pre>
  
  <p>This seems to follow the recommended way to do this, but doesn't work.</p>
  
  <p>Thanks for any help.</p>
  
  <p>For those who don't want to read all the details below to find the solution, the last part should read like this:</p>
  
  <pre><code>#list_p = POINTER(List)  # Not needed
  
  create = lib.DLL_CreateList
  create.argtypes = [POINTER(POINTER(List)),]
  create.restype = POINTER(List)
  control = POINTER(List)()
  list_p = create(byref(control))
  </code></pre>