On Mon, Dec 19, 2011 at 10:54 AM, Ganesh Borse <bganes...@gmail.com> wrote:

> I could know the use of unpack_from, but I could not understand the "fmt"
> part, i.e *"%dH" % nframes * nchannels*.
> Can you pls help me know, what is the purpose of two "%" signs in this
> statement?
>
>
That's python's string formatting.  See
http://docs.python.org/library/stdtypes.html#string-formatting-operations for
details.  Basically, it's building the format for the call to unpack_from
on the fly.  The "%dH" portion is calling for a single decimal value to
become part of the string (that's the "%d" portion).  That value comes from
multiplying nframes by nchannels.  So, for example, if nframes = 10 and
nchannels = 24, then the string becomes "240H".  That, in turn, tells the
program to unpack a sequence of 240 unsigned short values from the buffer.

-- 
Jerry
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to