What does zip mean?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Nov 14 12:06:07 CET 2014


Grant Edwards wrote:

> What the zipper on a coat does is convert two separate sequences into
> a single sequence where the members alternate between the two input
> sequences.  IOW if we want to do something analogous to a zipper
> fastener it should do this:
> 
> zip([a,b,c,d,e,f],[1,2,3,4,5,6])  => [a,1,b,2,c,3,d,4,e,5,f,6]


While that is correct, the name "zip" for 

    zip([a,b,c],[1,2,3])  => [(a,1), (b,2), (c,3)]


is long-established. I generally call the alternate behaviour "interleaving"
or "muxing", derived from multiplexer. While muxing and demuxing is
extremely important in circuit design and telecommunications, I've never
needed it in Python programming.




-- 
Steven




More information about the Python-list mailing list