title: How do I construct an array of ctype structures?
body: <pre><code>&gt;&gt;&gt; from ctypes import *
  &gt;&gt;&gt; class A(Structure):
  ...  _fields_ = [('a', c_int), ('b', c_int)]
  ...  def __init__(self, x):
  ...   self.a = x + 1
  ...   self.b = x + 2
  ... 
  &gt;&gt;&gt; a = A(1)
  &gt;&gt;&gt; a.a
  2
  &gt;&gt;&gt; a.b
  3
  &gt;&gt;&gt; b = (A * 2)(1, 2)
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  TypeError: expected A instance, got int
  </code></pre>
  
  <p>I am trying to construct an array of C structures in python and want the constructor to be called for each element in the array. How can I accomplish this?</p>