Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47358
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.051 |
| X-Spam-Evidence | '*H*': 0.90; '*S*': 0.00; 'subject:Python': 0.06; 'def': 0.12; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'pythonic': 0.16; 'alpha': 0.16; 'trying': 0.19; "i've": 0.25; 'values': 0.27; 'figure': 0.32; 'something': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'skip:o 20': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'most': 0.60; 'holding': 0.65; 'temporary': 0.65; 'around,': 0.84; 'received:50.22': 0.84 |
| Date | Fri, 7 Jun 2013 21:32:39 -0500 |
| From | Tim Chase <python.list@tim.thechases.com> |
| To | python-list@python.org |
| Subject | Idiomatic Python for incrementing pairs |
| 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 |
| 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.2868.1370658654.3114.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1370658654 news.xs4all.nl 15865 [2001:888:2000:d::a6]:38747 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:47358 |
Show key headers only | View raw
Playing around, I've been trying to figure out the most pythonic way
of incrementing multiple values based on the return of a function.
Something like
def calculate(params):
a = b = 0
if some_calculation(params):
a += 1
if other_calculation(params):
b += 1
return (a, b)
alpha = beta = 0
temp_a, temp_b = calculate(...)
alpha += temp_a
beta += temp_b
Is there a better way to do this without holding each temporary
result before using it to increment?
-tkc
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Idiomatic Python for incrementing pairs Tim Chase <python.list@tim.thechases.com> - 2013-06-07 21:32 -0500 Re: Idiomatic Python for incrementing pairs Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-08 06:39 +0000
csiph-web