Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'library,': 0.05; 'subject:Python': 0.05; 'received:209.85.160.174': 0.07; 'received :mail-gy0-f174.google.com': 0.07; 'python': 0.08; 'builtin': 0.09; 'am,': 0.12; 'def': 0.13; 'code?': 0.16; 'okay,': 0.16; 'op:': 0.16; 'x1,': 0.16; 'cc:addr:python-list': 0.16; 'language': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.21; 'header:In-Reply- To:1': 0.22; 'library.': 0.24; 'cc:2**0': 0.26; 'code': 0.26; 'function': 0.27; 'posted': 0.29; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; '3.x': 0.30; 'chris': 0.30; '---': 0.31; 'thu,': 0.32; 'actual': 0.32; 'there': 0.33; 'probably': 0.35; 'something': 0.35; 'received:209.85.160': 0.36; 'two': 0.36; 'comparing': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'uses': 0.38; 'should': 0.38; 'received:209': 0.39; 'march': 0.61; 'as:': 0.70; 'debate.': 0.84; 'quote,': 0.84; 'readability': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=qJyyIbMhtJXf7QmlZ71a9frTzZLWNkM1QNlojnD5Dw4=; b=ss7HODH3mTlm42K8J9/OFdEOo6LWknE921+/O2CdVKSuvoNStY3TK1WebfttgI7kyB lF4b61j0VcqzaYOmPniYheRbLbZoorz9BitNctuiGK3YDiMGEndcajWvcmIbP45ehF1E Fks1/+6CYwA1cNmhvbu4seWOHG2m4vcs0yk/cLzr+ha7RK/gfMme7R8+pMeZk8BXbbHS +s/n5aXhaZmUVV+CnRwHnOAlAlaTgMLYe7xxWD184qFZElb+WPhxeLdPf29qIyNHWV9q 0vu5VEeToTjeE4bp0Cn/PYJv3booD9ra5hEOh5xVEHyA9tta2U28+pyA60Zidp4CG3RJ letA== MIME-Version: 1.0 In-Reply-To: References: <4f612b19$0$1379$4fafbaef@reader2.news.tin.it> Date: Thu, 15 Mar 2012 20:54:30 +0000 Subject: Re: Python is readable From: Arnaud Delobelle To: Chris Angelico Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1331844872 news.xs4all.nl 6886 [2001:888:2000:d::a6]:34536 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21713 On 15 March 2012 00:27, Chris Angelico wrote: > On Thu, Mar 15, 2012 at 10:54 AM, Arnaud Delobelle wr= ote: >> I don't know this book and there may be a pedagogical reason for the >> implementation you quote, but pairwise_sum is probably better >> implemented in Python 3.X as: >> >> def pairwise_sum(list1, list2): >> =C2=A0 =C2=A0return [x1 + x2 for x1, x2 in zip(list1, list2)] > > Okay, here's something for debate. > > Should the readability of a language be gauged on the basis of its > standard library, or should you be comparing actual code? But here's the code posted by the OP: --- Python --- def pairwise_sum(list1, list2): result =3D [] for i in range(len(list1)): result.append(list1[i] + list2[i]) return result --- --- The code I posted uses one builtin function (zip), the code posted by the OP uses two (range and len). Neither uses the standard library. --=20 Arnaud