using *args in struct.pack
Question: I just read about the *args and **kwargs notation in python and decided to use
it with my functions that use struct.pack as such:

    
    
    def pack_floats(*args):
    
       return struct.pack('%df' %len(args), args)
    

But of course, it doesn't work because args is a tuple. If I wanted to pack
three numbers, I would call pack as such

    
    
    struct.pack('3f', 1, 2, 3)
    

Alternatively I could just run it through a loop and pack one number at a
time, but I don't know whether there is any performance difference between one
value at a time vs all values at a time.

Is there a way to write the pack_floats function without calling the pack
function inside a loop?


Answer: 
    >>> import struct
    >>> def pack_floats(*args):
    ...     return struct.pack('%df' %len(args), *args)
    ... 
    >>> pack_floats(0.1,1.2,2.3)
    '\xcd\xcc\xcc=\x9a\x99\x99?33\x13@'
    

