Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!feed.xsnews.nl!border-3.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.044 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; '===': 0.09; 'am,': 0.12; 'cc:addr:python-list': 0.15; '(2,': 0.16; '3),': 0.16; 'subject:function': 0.16; 'x2,': 0.16; 'wrote:': 0.16; 'wed,': 0.17; '>>>': 0.18; 'jan': 0.19; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'received:209.85.220': 0.27; 'cc:addr:gmail.com': 0.28; 'message- id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'chris': 0.30; 'subject:?': 0.30; 'url:library': 0.30; 'url:python': 0.36; 'cc:2**1': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.38; 'url:docs': 0.39; 'url:org': 0.39; 'received:209': 0.39; 'subject:: ': 0.39; 'taylor': 0.67; 'brown': 0.80; '(4,': 0.84; 'sender:addr:chris': 0.84; 'url:functions': 0.84; 'url:rebertia': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=7GvvrJe9hC9/rdqkGEfYfXmB5huYHqUgUEzXdkjWmhU=; b=FtFbC77tKKUpGBYVOEpLYtoz9vhaX10o086nT62Z/BTvfYbr7OICzTeKmdd2alj1J5 HfEWzaQUm4AKEg3IJny70pmAtutKs5tHfsY90YAEy9wrRFixEWhM0bmFmta4DgvmHuPm Xtma975FRIpywPJPkJl60VnMXLf0mYaKZ/8XY= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: References: Date: Wed, 18 Jan 2012 07:38:57 -0800 X-Google-Sender-Auth: mCuFjOUMeh7I5neYbdSmuKQRE60 Subject: Re: unzip function? From: Chris Rebert To: Rodrick Brown Content-Type: text/plain; charset=UTF-8 Cc: Neal Becker , python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326901142 news.xs4all.nl 6908 [2001:888:2000:d::a6]:41106 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19088 On Wed, Jan 18, 2012 at 7:31 AM, Rodrick Brown wrote: > On Wed, Jan 18, 2012 at 10:27 AM, Alec Taylor > wrote: >> >> http://docs.python.org/library/functions.html >> >>> x = [1, 2, 3] >> >>> y = [4, 5, 6] >> >>> zipped = zip(x, y) >> >>> zipped >> [(1, 4), (2, 5), (3, 6)] >> >>> x2, y2 = zip(*zipped) >> >>> x == list(x2) and y == list(y2) >> True > > > Alec can you explain this behavior zip(*zipped)? It's just the application of the http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists feature to a zip() [http://docs.python.org/library/functions.html#zip ] call. zip(*zipped) === zip(*[(1, 4), (2, 5), (3, 6)]) === zip((1, 4), (2, 5), (3, 6)) === [(1, 2, 3), (4, 5, 6)] Cheers, Chris -- http://rebertia.com