ANN: binario - simple work with binary files

Tim Roberts timr at
Tue Sep 2 02:35:19 CEST 2014

Rustom Mody <rustompmody at> wrote:

>On Tuesday, August 26, 2014 6:58:42 AM UTC+5:30, Tim Roberts wrote:

>> To the equivalent code with struct:
>>   import struct
>>   dscrp = "H?fs5B"
>>   f = open('file.dat')
>>   stuff = struct.unpack( dscrp, )
>>   print stuff
>> In both cases, you have to KNOW the format of the data beforehand.  If you
>> do a read_short where you happen to have written a float, disaster ensues.
>> I don't really see that you've added very much.
>I thought much the same.
>However notice your Its type is string.
>What if file.dat is a 1GB wav file?
  stuff = struct.unpack( dscrp, )

The point is that files already know how to position themselves.
Tim Roberts, timr at
Providenza & Boekelheide, Inc.

More information about the Python-list mailing list