[Tutor] Is this a job for zip(), or some other way?

Marilyn Davis marilyn at deliberate.com
Thu Mar 25 21:52:47 EST 2004


On Thu, 25 Mar 2004, Bob Gailer wrote:

> At 06:16 PM 3/25/2004, Gregor Lingl wrote:
> 
> 
> >Bob Gailer schrieb:
> >
> >>....
> >> >>> apply(zip, [ ('bob', 24, 457), ('mike', 20, 4567), ('steve', 30, 576)])
> >>[('bob', 'mike', 'steve'), (24, 20, 30), (457, 4567, 576)]
> >>
> >This works also:
> >
> > >>> zip(('bob', 24, 457), ('mike', 20, 4567), ('steve', 30, 576))
> >[('bob', 'mike', 'steve'), (24, 20, 30), (457, 4567, 576)]
> >
> >So in your case
> >
> > >>> zip(*[ ('bob', 24, 457), ('mike', 20, 4567), ('steve', 30, 576)])
> >[('bob', 'mike', 'steve'), (24, 20, 30), (457, 4567, 576)]
> 
> Yah, Ich habe geschrieben und Zie Zind correct. I was trying to remember 
> the * approach, my head would not deliver it in time.

What was gained with the *?

Is it that if you have:

L = [ ('bob', 24, 457), ('mike', 20, 4567), ('steve', 30, 576)]

You can then zip(*L) ?

Or is there something else?

Marilyn

> 
> Bob Gailer
> bgailer at alum.rpi.edu
> 303 442 2625 home
> 720 938 2625 cell 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

-- 




More information about the Tutor mailing list