>    I keep working around a little problem with unpacking in cases in which I 
> don't know how many elements I get. Consider this:
> 
>       def  tabulate_lists (*arbitray_number_of_lists):
>             table = zip (arbitray_number_of_lists)
>             for record in table:
>                # etc ...
> 
> This does not work, because the zip function also has an *arg parameter, 
> which expects an arbitrary length enumeration of arguments
> which it would turn into a tuple (lists in this case). Now my function does 
> exactly the same thing ahead of zip. So, before I pass
> the tuple "arbitrary_number_of_lists" to zip, I 'd need to unpack it but the 
> only way I know of is into variables:
> 
>          list1, list2, list3 = arbitrary_number_of_lists
>          zip (list1, list2, list3)


I don't get your problem here. This works for me:

args = [range(5) for i in xrange(5)]

print zip(*args)

> With arbitrary number of lists it cannot be done this way.
> 
> Question: Is there an unpacking mechanism for cases in which I don't 
> know--and don't need to know--how many elements I get, or an
> argument passing mechanism that is the inverse of the tuplifier (*args)?

No.

It looks a little bit as if you aren't aware of the symetry behind the * 
and **-argument-passing schemes. I suggest reading up on them.

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to