Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9510

Re: Please critique my script

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'happen,': 0.07; 'python': 0.08; '(it': 0.09; 'differing': 0.09; 'am,': 0.13; 'received:209.85.214.174': 0.13; 'received:mail- iw0-f174.google.com': 0.13; 'wrote:': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lambda': 0.16; 'edward': 0.16; 'meant': 0.17; 'header:In-Reply-To:1': 0.22; 'assume': 0.23; 'code': 0.24; "i'm": 0.27; 'fri,': 0.28; 'received:209.85.214': 0.28; 'message-id:@mail.gmail.com': 0.28; 'elements': 0.29; 'lists': 0.29; "won't": 0.32; 'chris': 0.32; 'done': 0.33; 'to:addr:python-list': 0.34; 'however,': 0.34; '\xa0\xa0\xa0': 0.34; 'functions.': 0.37; 'subject:Please': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'two': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'your': 0.60; 'regexps': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=DOe9WLO4h+69nQQNowS+5xTGCDF/U3a/2JYazx9j8F8=; b=mloImxGakwF8JAEUGby2j9ZchskJXa98fMiKaG5Zb2x9NhDL6s80hHyJt1nbXqNsqd AkwvUrH43L8yl0l5qkcETDYelP67034mvt7pbRDsdbfH3SDkaGcXruVzVndjkNLzi1VQ tAFY6QT5IUgVcqR0ns74PKgrYtDwQ7o/kreDc=
MIME-Version 1.0
In-Reply-To <77AE044B1BF3944FAE2435F395F11B4B01859CD7@clt-exmb02.bbtnet.com>
References <77AE044B1BF3944FAE2435F395F11B4B01859CD7@clt-exmb02.bbtnet.com>
Date Fri, 15 Jul 2011 16:36:32 +1000
Subject Re: Please critique my script
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1047.1310711795.1164.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1310711795 news.xs4all.nl 23854 [2001:888:2000:d::a6]:33644
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:9510

Show key headers only | View raw


On Fri, Jul 15, 2011 at 4:03 AM, Ellerbee, Edward <EEllerbee@bbandt.com> wrote:
> for makenewlist in range(0,count):
>     sortlist.append(npalist.pop(0) + nxxlist.pop(0))

This can alternatively be done with map():

sortlist = map(lambda x,y: x+y, npalist, nxxlist)

However, I'm not sure what your code is meant to do if the two lists
have differing numbers of elements (if the two regexps turn up
differing numbers of results). If you can assume that this won't
happen, the simple map call will do the job.

(It would have been a lot cleaner if Python exposed its operators as
functions. In Pike, that lambda would simply be `+ (backtick-plus).)

Chris Angelico

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Please critique my script Chris Angelico <rosuav@gmail.com> - 2011-07-15 16:36 +1000
  Re: Please critique my script "bruno.desthuilliers@gmail.com" <bruno.desthuilliers@gmail.com> - 2011-07-15 00:19 -0700
    Re: Please critique my script Chris Angelico <rosuav@gmail.com> - 2011-07-15 17:57 +1000

csiph-web