Re: struct unpack issue

2008-06-13 Thread Miles
On Fri, Jun 13, 2008 at 9:27 PM, Ping Zhao <[EMAIL PROTECTED]> wrote: > However, when I tried to rewrite them in short: > > header = struct.unpack('2s1i', self.__read(src, 6)) > ... > It was weired that the required argument length increased to 8. This is an alignment issue; if you don't specify a

Re: struct unpack issue

2008-06-13 Thread Peter Otten
Ping Zhao wrote: > I am writing a small program to decode MS bitmap image. When I use > statements as follow, it works fine: > > header['sig'] = str(struct.unpack('2s', self.__read(src, 2))[0]) > header['len'] = int(struct.unpack('1i', self.__read(src, 4))[0]) > > However, when I tried to rewr