title: Calling from_buffer_copy in the constructor of inherited ctypes.Structure class
body: <p>I have the following piece of code:</p>
  
  <pre><code>class MyStruct(ctypes.Structure):
        _fields_= [('id', ctypes.uint),
                   ('perm', ctypes.uint)]
  </code></pre>
  
  <p>When the class is defined, i'm able to copy data from buffer directly on my fields. 
  Eg:</p>
  
  <pre><code>ms = MyStruct.from_buffer_copy("\xAA\xAA\xAA\xAA\x11\x11\x11\x11")
  print ms.id, ms.perm
  </code></pre>
  
  <p>Everythings works fine, here <strong>id</strong> will be <em>0xAAAAAAAA</em> and <strong>perm</strong> equals to <em>0x11111111</em>.</p>
  
  <p>Now, i tried to do the same thing during the instantiation, with the following code:</p>
  
  <pre><code>class MyStruct(ctypes.Structure):
        _fields_= [('id', ctypes.uint),
                   ('perm', ctypes.uint)]
        def __init__(self):
            super(MyStruct, self).__init__()
            self.from_buffer_copy("\xAA\xAA\xAA\xAA\x11\x11\x11\x11")
  
  ms = MyStruct()
  print ms.id, ms.perm
  </code></pre>
  
  <p>But my code raises an error with the following statement : </p>
  
  <blockquote>
    <p>AttributeError: 'MyStruct' object has no attribute 'from_buffer_copy'</p>
  </blockquote>
  
  <p>After some research i found that <code>from_buffer_copy</code> is a <code>ctypes._CData</code> method. On the documentation we can read that <code>_CData</code> class is <a href="http://docs.python.org/library/ctypes.html#ctypes._CData" rel="nofollow">non-public class</a>.</p>
  
  <p>So here my problem. I would like to use <code>from_buffer_copy</code> in the constructor but it looks 'not callable' at this moment. Could you help me ? </p>
  
  <p>Thanks in advance for your reply
  Regards</p>
  
  <p>PS: I don't want to use the style <code>super(MyStruct,self).__init__(id=0x44444444,perm=0x11111111)</code> because on my real code there are a lot of arguments on my <em>fields</em> variable.</p>