Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40198
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; '#if': 0.05; 'modified': 0.05; 'arguments': 0.07; 'subject:code': 0.07; 'cc:addr:python-list': 0.10; '-tkc': 0.16; 'attr': 0.16; 'cleaner': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'wrote:': 0.17; 'tim': 0.18; 'otherwise,': 0.20; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'subject:please': 0.27; 'behavior.': 0.29; 'chase': 0.29; 'value)': 0.29; 'ends': 0.30; 'figure': 0.30; 'code': 0.31; 'maintained': 0.33; 'pm,': 0.35; 'something': 0.35; 'useful': 0.36; 'charset:us-ascii': 0.36; 'beyond': 0.37; 'ones': 0.37; 'skip:z 10': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'received:50.22': 0.84; 'taken.': 0.84; 'angel': 0.93 |
| Date | Thu, 28 Feb 2013 16:44:37 -0600 |
| From | Tim Chase <python.list@tim.thechases.com> |
| To | Dave Angel <davea@davea.name> |
| Subject | Re: suggestions for improving code fragment please |
| In-Reply-To | <512FCBF2.2040300@davea.name> |
| References | <u8idnaoktKrcKbLMnZ2dnUVZ8uednZ2d@brightview.co.uk> <20130228143715.4e5ada26@bigbox.christie.dr> <512FCBF2.2040300@davea.name> |
| X-Mailer | Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - boston.accountservergroup.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - tim.thechases.com |
| 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 <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.2692.1362091374.2939.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1362091374 news.xs4all.nl 6949 [2001:888:2000:d::a6]:36003 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:40198 |
Show key headers only | View raw
On 2013-02-28 16:28, Dave Angel wrote:
> On 02/28/2013 03:37 PM, Tim Chase wrote:
> > for attr in ("myparm1", "myparm2", "myparm3", ...):
> > if arglist:
> > setattr(self, attr, arglist.pop(0))
> > else:
> > break
> >
> Or something like (untested):
>
> for name, value in zip(["myparm1", "myparm2", "myparm3"],
> arglist): setattr(self, name, value)
> arglist = [] #if you care how it ends up
The OP's code modified arglist by .pop(0) so I maintained the same
behavior. This is useful if additional arguments beyond the N named
ones are used for some other purpose and you don't want to figure out
how many were taken. Otherwise, if one wants to keep arglist, Dave's
zip() solution is a cleaner way to go.
-tkc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
suggestions for improving code fragment please The Night Tripper <jkn+gg@nicorp.co.uk> - 2013-02-28 19:47 +0000
Re: suggestions for improving code fragment please Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-28 11:55 -0800
Re: suggestions for improving code fragment please Joel Goldstick <joel.goldstick@gmail.com> - 2013-02-28 14:56 -0500
Re: suggestions for improving code fragment please The Night Tripper <jkn+gg@nicorp.co.uk> - 2013-02-28 23:20 +0000
Re: suggestions for improving code fragment please Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-28 12:58 -0700
Re: suggestions for improving code fragment please Tim Chase <python.list@tim.thechases.com> - 2013-02-28 14:37 -0600
Re: suggestions for improving code fragment please MRAB <python@mrabarnett.plus.com> - 2013-02-28 21:13 +0000
Re: suggestions for improving code fragment please Mitya Sirenef <msirenef@lightbird.net> - 2013-02-28 16:22 -0500
Re: suggestions for improving code fragment please Dave Angel <davea@davea.name> - 2013-02-28 16:28 -0500
Re: suggestions for improving code fragment please Terry Reedy <tjreedy@udel.edu> - 2013-02-28 16:30 -0500
Re: suggestions for improving code fragment please Tim Chase <python.list@tim.thechases.com> - 2013-02-28 16:44 -0600
Re: suggestions for improving code fragment please Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-01 02:44 +0000
csiph-web