How to convert a list/tuple into an function argument list easily?
Neal Norwitz
neal at metaslash.com
Sun Dec 15 22:03:36 EST 2002
On Sun, 15 Dec 2002 21:20:59 -0500, Pierre Rouleau wrote:
>
> This fails:
> >>> val = struct.pack('<LHH', record)
>
> But this works:
> >>> val = struct.pack('<LHH', record[0], record[1], record[2])
>
> is there an easy way to convert a tuple into all of its elements so that
> i could write something like:
>
> val = struct.pack('<LHH', elementsOf(record))
val = struct.pack('<LHH', *record)
works in Python 2.0 or 2.1 and above. I forget when it was added.
Neal
More information about the Python-list
mailing list