Binary File Editor

garbett at my-deja.com garbett at my-deja.com
Thu Aug 17 08:57:12 EDT 2000


In article <8nemvc$d1j$1 at nnrp1.deja.com>,
  garbett at my-deja.com wrote:
> I want to make an editor (in python!) that edits binary files. Most of
> the data is long/string/long then a big sequence of raw bytes. The raw
> bytes I'm not interested in editing, but maybe switching for a
different
> set of raw bytes. The files are actually a proprietary collection of
wav
> files with additional info.
>

I've not gotten any response, so I've started trying to write the parser
in python and remember why I got stuck the first time I tried.

The first four bytes of the file are a string denoting type, the next
four is an integer.

Quite simply, how do I read the first four bytes into a string and the
next four into an integer in python? If I can do this I think the rest
is downhill.

The FileType supports a read, i.e. 'f.read([n])  Reads at most n bytes'
but how could this be used to read into python native types???

Shawn Garbett


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list