Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!news2.euro.net!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.088 X-Spam-Evidence: '*H*': 0.83; '*S*': 0.00; 'subject:code': 0.07; 'cc:addr:python-list': 0.10; 'wrote:': 0.17; 'thu,': 0.17; 'feb': 0.19; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In- Reply-To:1': 0.25; 'subject:please': 0.27; 'message- id:@mail.gmail.com': 0.27; 'url:mailman': 0.29; "i'm": 0.29; 'url:python': 0.32; 'url:listinfo': 0.32; 'received:google.com': 0.34; 'thanks': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'url:org': 0.36; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'url:mail': 0.40; 'night': 0.62; '2013': 0.84; 'dumb': 0.84; 'joel': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=AFzAk63W9aAllJyLs5RtV27QPicXkZaLXLx8JklpuaY=; b=XMzVxB+sk4ryIR1GeOy1y3LiFddbbHE4cBMOK2R1o/nxvH3mtUD3YJLXGe2X/KIA24 eiX3EANmPdsg7yj/Dr5OGZFBn5vlZJqFUItlHroUYFn/9M0xKWvXFFARZbvodBwf72/K F5SQBtVMriTzn4M0yzHOXpR8qxAnpeZKLXA5aW7br67s28fhE0DITvyz9qsoojvCCo6O A2DWjLtDxvvpcwdqaOIEuORUIZO8upbsnBCtY4xrDj/Yalhnuw/TqKAFCqPybjyRCU9w 2yB4QskWEAwu6BT9FFR1G8mrGIB1osiPKNyuw2b/Ooi2bFN48/m4BTBrH7hI0KZ8f5mE BWfQ== MIME-Version: 1.0 X-Received: by 10.58.220.66 with SMTP id pu2mr3017500vec.60.1362081407519; Thu, 28 Feb 2013 11:56:47 -0800 (PST) In-Reply-To: References: Date: Thu, 28 Feb 2013 14:56:47 -0500 Subject: Re: suggestions for improving code fragment please From: Joel Goldstick To: jkn+gg@nicorp.co.uk Content-Type: multipart/alternative; boundary=047d7bd6adba73541904d6ce4a95 Cc: "python-list@python.org" 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: 89 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362081415 news.xs4all.nl 6920 [2001:888:2000:d::a6]:33166 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40166 --047d7bd6adba73541904d6ce4a95 Content-Type: text/plain; charset=UTF-8 On Thu, Feb 28, 2013 at 2:47 PM, The Night Tripper wrote: > Hi there > I'm being very dumb ... how can I simplify this fragment? > i = 0 while arglist: self.myparm[i] = arglist.pop(0) i += 1 > if arglist: > arglist.pop(0) > if arglist: > self.myparm1 = arglist.pop(0) > if arglist: > self.myparm2 = arglist.pop(0) > if arglist: > self.myparm3 = arglist.pop(0) > if arglist: > self.parm4 = arglist.pop(0) > # ... > > Thanks > J^n > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick http://joelgoldstick.com --047d7bd6adba73541904d6ce4a95 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable



On Thu, Feb 28, 2013 at 2:47 PM, The Night Tripper <jkn+gg@nicor= p.co.uk> wrote:
Hi there
=C2=A0 =C2=A0 I'm being very dumb ... how can I simplify this fragment?=
i =3D 0
while arglist:
= =C2=A0=C2=A0=C2=A0 self.myparm[i] =3D arglist.pop(0)
=C2=A0= =C2=A0=C2=A0 i +=3D 1



=C2=A0 =C2=A0 =C2=A0 =C2=A0 if arglist:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 arglist.pop(0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if arglist:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.myparm1 =3D ar= glist.pop(0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if arglist:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.= myparm2 =3D arglist.pop(0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if ar= glist:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 self.myparm3 =3D arglist.pop(0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 if arglist:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 self.parm4 =3D arglist.pop(0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 # ...

=C2=A0 =C2=A0 Thanks
=C2=A0 =C2=A0 J^n


--
http://mail.python.org/mailman/listinfo/python-list



--
--047d7bd6adba73541904d6ce4a95--