[Tutor] curious struct problem
Alan Gauld
alan.gauld at btinternet.com
Mon Feb 5 20:05:27 CET 2007
"Marcus Goldfish" <magoldfish at gmail.com> wrote
> I just want to troubleshoot the problem. The error is reproduced as
> a
> comment below the source. As far as I know, there are no globals; I
> am
> invoking this from a command line prompt: python demux.py foo.bin 1
> 1
> def demux(fname, ch=1, nchan=1):
> fmt = str(nchan) + 'h' # nchan of short (int16)
> blockSize = struct.calcsize(fmt)
Try a print statement here:
print fmt,' = ',blockSize
> # file setup
> infile = open(fname, 'rb')
> #outfile = open(fname + 'ch' + str(ch), 'wb')
>
> # iterate over data
> chunk = infile.read(blockSize)
> while chunk:
And another print here
print chunk
Does chunk match the fmt/blockSize above?
Alan G
More information about the Tutor
mailing list