Packing a list of lists with struct.pack()
Fredrik Lundh
fredrik at pythonware.com
Thu Apr 27 07:20:25 EDT 2006
Panos Laganakos wrote:
> What I don't understand is what are you doing with *(...), this is
> supposed to pack its contents as a list?
the *arg form treats each value in the arg sequence as a separate argument.
for example,
arg = 1, 2, 3
function(*arg)
is the same thing as
function(1, 2, 3)
when used with a generator expression, *(genexp) simply fetches the arguments
from the generated sequence.
(note that struct.pack expects a format string plus N additional arguments, not
a format string and an N-item sequence)
</F>
More information about the Python-list
mailing list