"Marcus Goldfish" <[EMAIL PROTECTED]> wrote > interactively in the IPython shell, but not as a function invoked > from a > command line (Windows). Can someone point out my error? Thanks!
One problem I dsee is that the function does not return anything. It stores it in a local variable x which is garbage collected when the function exits. Could that be the problem? It would help if you tell us exactly how it doesn't work. Do you get an error message? If so what - exactly? Is the data written anyplace? Is the format wrong? What exactly is the problem we are trying to diagnose? Without specific information we are just guessing. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld > import struct > > def demux(filename, channel, nchannels): > "Demultiplexes a stream of shorts (signed int16) from a file." > fmt = str(nchannels) + 'h' > sz = struct.calcsize(fmt) > > infile = open(fname, 'rb') > chunk = infile.read(sz) > while chunk: > x = struct.unpack(fmt, chunk) > chunk = infile.read(sz) > infile.close() > > #struct.error: unpack str size does no match format > -------------------------------------------------------------------------------- > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor