How to convert a list/tuple into an function argument list easily?

Andrew Koenig ark at research.att.com
Sun Dec 15 22:15:26 EST 2002


Pierre> But this works:

>>>> val = struct.pack('<LHH', record[0], record[1], record[2])
>>>> 

Pierre> Question:
Pierre> =========

Pierre> is there an easy way to convert a tuple into all of its elements so
Pierre> that i could write something like:

Pierre> 	val = struct.pack('<LHH', elementsOf(record))

How about this?

        val = struct.pack('<LHH', *record)


-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark



More information about the Python-list mailing list