opposite of zip()?

Paddy paddy3118 at googlemail.com
Sat Dec 15 00:54:22 EST 2007


On Dec 15, 5:47 am, igor.tatari... at gmail.com wrote:
> Given a bunch of arrays, if I want to create tuples, there is
> zip(arrays). What if I want to do the opposite: break a tuple up and
> append the values to given arrays:
>    map(append, arrays, tupl)
> except there is no unbound append() (List.append() does not exist,
> right?).
>
> Without append(), I am forced to write a (slow) explicit loop:
>   for (a, v) in zip(arrays, tupl):
>       a.append(v)
>
> I assume using an index variable instead wouldn't be much faster.
>
> Is there a better solution?
>
> Thanks,
> igor

I can't quite get what you require from your explanation. Do you have
sample input & output?

Maybe this:
 http://paddy3118.blogspot.com/2007/02/unzip-un-needed-in-python.html
Will help.

- Paddy.



More information about the Python-list mailing list