elementary tuple question. (sorry)
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu Apr 5 17:23:52 EDT 2007
En Thu, 05 Apr 2007 18:08:14 -0300, Steven W. Orr <steveo at syslang.net>
escribió:
> I have a tuple that I got from struct.unpack. Now I want to pass the data
> from the returned tuple to struct.pack
>
>>>> fmt
> 'l 10l 11i h 4h c 47c 0l'
>>>> struct.pack(fmt, tup)
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> struct.error: required argument is not an integer
>
> What's the idiom to pass the data in tup?
Try the builtin help system:
py> help(struct.pack)
Help on function pack in module struct:
pack(fmt, *args)
Return string containing values v1, v2, ... packed according to fmt.
See struct.__doc__ for more on format strings.
So struct.pack(fmt, *tup) should work - try and see.
--
Gabriel Genellina
More information about the Python-list
mailing list