Mohammad Moghimi wrote: > Hi there > can you describe why last two lines print different numbers > > --------------------------------------------------------------- > import struct > struct.calcsize("lH") > struct.calcsize("Hl") > ---------------------------------------------------------------
Because by default struct uses "native" alignment. Your processor presumably aligns longs on long boundaries so two pad bytes are inserted in the Hl case. You can force no alignment by using "standard" alignment. For example on Windows: >>> from struct import calcsize >>> calcsize('Hl') 8 >>> calcsize('lH') 6 >>> calcsize('=Hl') 6 >>> calcsize('=lH') 6 Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor