On Mar 2, 12:53 am, "Bart Ogryczak" <[EMAIL PROTECTED]> wrote:
>
> import struct
> buf = open('somefile','rb').read()
> count1 = lambda x: (x&1)+(x&2>0)+(x&4>0)+(x&8>0)+(x&16>0)+(x&32>0)+
> (x&64>0)+(x&128>0)
> byteOnes = map(count1,struct.unpack('B'*len(buf),buf))

byteOnes = map(count1,struct.unpack('%dB'%len(buf),buf))

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to