Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Oscar Benjamin Newsgroups: comp.lang.python Subject: Re: Simple exercise Date: Mon, 14 Mar 2016 15:06:15 +0000 Lines: 25 Message-ID: References: <88c5b5fa-66a0-461a-8ae4-b3264b32f679@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 1PEZFHRWIqcaIlkdwl1UXgRaPbM2APS8hlGD8QLfrT6g== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'reason,': 0.07; 'cc:addr :python-list': 0.09; '[1,': 0.09; 'length.': 0.09; 'warn': 0.09; 'index': 0.13; '2016': 0.16; 'cc:name:python list': 0.16; 'dropping': 0.16; 'iterables': 0.16; 'len': 0.16; 'length,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'meant': 0.22; 'pass': 0.22; 'header:In-Reply-To:1': 0.24; 'error': 0.27; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'values': 0.28; 'strongly': 0.30; 'anyone': 0.32; 'items.': 0.33; 'subject:Simple': 0.33; 'received:google.com': 0.35; 'received:209.85': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'johnson': 0.37; 'received:209': 0.38; 'or,': 0.38; 'rather': 0.39; 'avoid': 0.61; 'course': 0.62; 'necessarily': 0.63; 'march': 0.64; 'matter.': 0.66; 'percent': 0.66; 'oscar': 0.84; 'absolutely': 0.88; 'safer': 0.91; 'rick': 0.93; 'hundred': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=uS4hQMi8XIhWRPXG3/JhZOBAMVqZTT40E6ouQgiriqk=; b=U2Gwb0St8Uiy43009RtucLZEvE2+G2y1fvYah+9MbBfDU+h5i6kFZMojdHyjPUUAAl nXYhj2xbskf2WwnNr0RlDUOhxguU6RZZ/OEX5DBRD1Mth6J4vio3UMzigp4ycczSeKP1 oEq1RfkzqFPXCgrdGxfBNsgB05Z47wD3jxUx+odCgiGbADAGqJABh+7u7d5pjzOFQPV5 idTMHwow47aU5LxGu2MorQpiaU1uK6EcYs8/N95GsGBXoCvMbFbMmzZNm1oq1MY8BMju ipHZqBzxs4RqWAVgAX9YGNJIA1adNOhHzTZtVZWHjngLX1OE7u5LpXB/BlBEQehlQ3/V /R+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=uS4hQMi8XIhWRPXG3/JhZOBAMVqZTT40E6ouQgiriqk=; b=bYb5mt4LwOuS0Mj0pZMia1O28XnFvfvGmcD3tThmHHL+ZSUXYML9MrGAB6U0oUJ9TW hNWTZELKxCrpFLqEALvEH7swwpZe8Rfb1pThduScj8IHWFOOM1rS6+2EQ8hGTJHXCA/u mK4cKrpu+trg5SoLD+9Ry+OBHdW9uaRx7X7V/vaF6QTt4Y6WU8Thcx5wxzb4HRJ/eUq9 eoT3ZOVRx+uhHBbD/eOSxcM4NxLYOnbnnHGh88oXWRQ/qwhT0jAealcxyq8WvTpYCmVT jyB2f/c2gM/PFhkwuzrr7UZRLKcVYR7Gv+L1K33vmlj/qnYsIROCh6Bqz+tjS+sJwrJy Q4uw== X-Gm-Message-State: AD7BkJI1IeSzgF6Ew3+9eC+PRsTMNTTB8t6++KkA1XE4GIE3izNfGzLOIoVTx2fTbhXxYo7qUU+IRCXDQHqk5g== X-Received: by 10.112.198.132 with SMTP id jc4mr8486234lbc.120.1457967995573; Mon, 14 Mar 2016 08:06:35 -0700 (PDT) In-Reply-To: <88c5b5fa-66a0-461a-8ae4-b3264b32f679@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104819 On 14 March 2016 at 14:35, Rick Johnson wrote: > > I would strongly warn anyone against using the zip function > unless ... > I meant to say: absolutely, one hundred percent *SURE*, that > both sequences are of the same length, or, absolutely one > hundred percent *SURE*, that dropping values is not going to > matter. For that reason, i avoid the zip function like the > plague. I would much rather get an index error, than let an > error pass silently. I also think it's unfortunate that zip silently discards items. Almost always when I use zip I would prefer to see an error when the two iterables are not of the same length. Of course you're not necessarily safer with len and range: a = [1, 2, 3] b = 'abcde' for n in range(len(a)): print(a[n], b[n]) -- Oscar