Extracting 3-byte integers

Bob Greschke bob at passcal.nmt.edu
Tue Jun 27 19:46:16 CEST 2006

>I have some binary data read from a file that is arranged like
>   <3-byte int> <3-byte int> <3-byte int> etc.
> The "ints" are big-endian and there are 169 of them.  Is there any clever 
> way to convert these to regular Python ints other than (struct) unpack'ing 
> them one at a time and doing the math?

Thanks guys!  I was looking for a 'one liner' of some kind, but I guess 
there isn't one (too bad you can't tell array or struct.unpack how many 
bytes you want an integer to be).  Yeah, these are signed ints so I'll have 
to convert them.

To me balancing my checkbook involves higher "math". :)


More information about the Python-list mailing list