title: Python ctype-bitfields: get bitfield location
body: <p>I have created a ctype bitfield structure with a corresponding Union to access it both by single bitfield and by integer value.
  I was able to set the single field using a variable that contains the name of the field, but now I'd like to know to which byte the specific field belongs to.
  Here is an example of my code:</p>
  
  <pre><code>import ctypes
  
  c_short = ctypes.c_uint16
  
  class Flags_bits(ctypes.LittleEndianStructure):
      _fields_ = [
          ("bitField1", c_short, 1),
          ("bitField2", c_short, 4),
          ("bitField3", c_short, 6),
          ("bitField4", c_short, 1),
          ("bitField5", c_short, 2),
          ("bitField6", c_short, 2),
  
          ("bitField7", c_short, 6),
          ("bitField8", c_short, 4),
          ("bitField9", c_short, 4),
          ("bitField10", c_short, 1),
          ("bitField11", c_short, 1)]
  
  class Flags(ctypes.Union):
      _fields_ = [("b", Flags_bits),
                  ("asInt", c_short*6)]
  
  def setFlag (flagName, value):
      flags = Flags()
      setattr(flags.b, flagName, value)        
      print getattr(flags.b, flagName)
  </code></pre>
  
  <p>Now what I want to know is to which integer my flag  belongs to (i.e. to which flags.asInt[i]), I was looking for a sort of "get_location" attribute to get the flag location in the structure and from this retrieve the 'i' index of the integer, but I couldn't find anything
  Is there a simple way to do that?</p>
  
  <p>Thanks in advance for every reply!</p>