Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.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.072 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'python': 0.09; 'sat,': 0.15; "'bar']": 0.16; 'head,': 0.16; 'oct': 0.16; 'stumbled': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'please?': 0.22; 'split': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; "d'aprano": 0.29; 'steven': 0.29; 'tail': 0.29; 'could': 0.32; 'to:addr:python-list': 0.33; 'charset:us-ascii': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'received:10': 0.38; 'sure': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'help': 0.40; 'content-disposition:inline': 0.60; 'thomas': 0.62; 'more': 0.63; 'it!': 0.64; "'foo'": 0.84; 'received:10.94': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uni-mainz.de; i=@uni-mainz.de; q=dns/txt; s=ironport; t=1349732829; x=1381268829; h=date:from:to:subject:message-id:references:mime-version: in-reply-to; bh=gimljn93F34j0IlC/HIr+G+5/i7AuluUnfkgpvG9MkM=; b=QO1dbypcYiFc0wR/LnJUwpyJQnbjS9/RPbeotKhhz6iKhpU6fagj+3Ms RfJXlEdOowayFyPEIOKhBbVZ6mAPbROxDeAvQ48OZeG45V1i0SJ1/yhUR 8pCmQV3evaU+6LXpcTb3uXGjiMPvkpbePjZaaNDRRXsobCDvdAHMYI402 Q=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtEEAFJIc1AKXgZQ/2dsb2JhbABFu26ESoIgAQEFOk8LGB4QFCkgiBy6NotPgm9IgXlgA5VqAZAugmAPghU Date: Mon, 8 Oct 2012 23:45:58 +0200 From: Thomas Bach To: Subject: Re: Unpaking Tuple References: <801f0e2c-7d1d-4e91-bec5-78c5e53a70ec@googlegroups.com> <50704975$0$29978$c3e8da3$5496439d@news.astraweb.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <50704975$0$29978$c3e8da3$5496439d@news.astraweb.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [88.69.178.148] X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1349732829 news.xs4all.nl 6898 [2001:888:2000:d::a6]:38280 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30976 Hi there, On Sat, Oct 06, 2012 at 03:08:38PM +0000, Steven D'Aprano wrote: > > my_tuple = my_tuple[:4] > a,b,c,d = my_tuple if len(my_tuple) == 4 else (my_tuple + (None,)*4)[:4] > Are you sure this works as you expect? I just stumbled over the following: $ python Python 3.2.3 (default, Jun 25 2012, 23:10:56) [GCC 4.7.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> split = ['foo', 'bar'] >>> head, tail = split if len(split) == 2 else split[0], None >>> head ['foo', 'bar'] >>> tail >>> I don't get it! Could someone help me, please? Why is head not 'foo' and tail not 'bar'? Regards, Thomas