<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18939">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>Hi,</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>I'm trying to rewrite a c program in python &
encountered several problems. I have some data structures in my c program like
below:</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>typedef struct</FONT></DIV>
<DIV><FONT size=2 face=Arial>{</FONT></DIV>
<DIV><FONT size=2 face=Arial> unsigned short
size;</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial> unsigned short
reserved:8;</FONT></DIV>
<DIV><FONT size=2 face=Arial> unsigned short
var_a1:2;</FONT></DIV>
<DIV><FONT size=2 face=Arial> unsigned short
var_a2:2;</FONT></DIV>
<DIV><FONT size=2 face=Arial> unsigned short
var_a3:2;</FONT></DIV>
<DIV><FONT size=2 face=Arial> unsigned short
var_a4:2;</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial> unsigned int
var_a5;</FONT></DIV>
<DIV><FONT size=2 face=Arial>}structa;</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial> </FONT><FONT size=2 face=Arial><FONT size=2
face=Arial>typedef struct</FONT></DIV>
<DIV>
<DIV><FONT size=2 face=Arial>{</FONT></DIV>
<DIV><FONT size=2 face=Arial> unsigned short
size;</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial> unsigned char
reserved:4;</FONT></DIV>
<DIV><FONT size=2 face=Arial> unsigned char
var_b1:1;</FONT></DIV>
<DIV><FONT size=2 face=Arial> unsigned char
var_b2:1;</FONT></DIV>
<DIV><FONT size=2 face=Arial> unsigned char
var_b3:1;</FONT></DIV>
<DIV><FONT size=2 face=Arial> unsigned char
var_b4:1;</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial> structa
var_structa;</FONT></DIV>
<DIV><FONT size=2 face=Arial>}structb;</FONT></DIV>
<DIV> </DIV>
<DIV>I tried to code the above in python but only got this far:</DIV>
<DIV> </DIV>
<DIV>class StructA(object):</DIV>
<DIV> def __init__(self, size=0)</DIV>
<DIV> self.size = size</DIV>
<DIV> </DIV>
<DIV>class StructB(object):</DIV>
<DIV> def __init__(self, size=0)</DIV>
<DIV> </DIV>
<DIV>Any equivalent for c data structures & bit fields in python? And
how do I define var_structa (in structb) in python?</DIV>
<DIV> </DIV>
<DIV>Regards,</DIV>
<DIV>Kwan.</DIV></FONT></DIV></BODY></HTML>