elementary tuple question. (sorry)

attn.steven.kuo at gmail.com attn.steven.kuo at gmail.com
Thu Apr 5 23:17:25 CEST 2007


On Apr 5, 2:08 pm, "Steven W. Orr" <ste... at syslang.net> wrote:
> 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

mystring = struct.pack(fmt, *tup)

--
Hope this helps,
Steven




More information about the Python-list mailing list