Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'subject:Python': 0.06; '-0500': 0.09; 'python': 0.11; 'def': 0.12; '-tkc': 0.16; 'alpha,': 0.16; 'pairs': 0.16; 'pythonic': 0.16; 'alpha': 0.16; 'trying': 0.19; 'to:name:python-list@python.org': 0.22; 'received:65.55.116': 0.24; "i've": 0.25; '>': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'url:mailman': 0.30; 'figure': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'date:': 0.34; 'something': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.37; 'skip:o 20': 0.38; 'to:addr :python-list': 0.38; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'most': 0.60; 'email name:python-list': 0.65; 'holding': 0.65; 'temporary': 0.65; 'around,': 0.84; '2013': 0.98 X-TMN: [88QxWnv5ECpG0KGKgj52zk8l0IEucSkP] X-Originating-Email: [carlosnepomuceno@outlook.com] Content-Type: multipart/alternative; boundary="_29d5b315-b00d-41fb-a293-16fdc3365797_" From: Carlos Nepomuceno To: "python-list@python.org" Subject: RE: Idiomatic Python for incrementing pairs Date: Sat, 8 Jun 2013 07:04:21 +0300 Importance: Normal In-Reply-To: <20130607213239.3e39a448@bigbox.christie.dr> References: <20130607213239.3e39a448@bigbox.christie.dr> MIME-Version: 1.0 X-OriginalArrivalTime: 08 Jun 2013 04:04:21.0586 (UTC) FILETIME=[416CFB20:01CE63FD] 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: 77 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370664271 news.xs4all.nl 15912 [2001:888:2000:d::a6]:56607 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47363 --_29d5b315-b00d-41fb-a293-16fdc3365797_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable alpha=2C beta =3D (1 if some_calculation(params) else 0=2C 1 if other_calcu= lation(params) else 0) > Date: Fri=2C 7 Jun 2013 21:32:39 -0500 > From: python.list@tim.thechases.com > To: python-list@python.org > Subject: Idiomatic Python for incrementing pairs >=20 > Playing around=2C I've been trying to figure out the most pythonic way > of incrementing multiple values based on the return of a function. > Something like >=20 > def calculate(params): > a =3D b =3D 0 > if some_calculation(params): > a +=3D 1 > if other_calculation(params): > b +=3D 1 > return (a=2C b) >=20 > alpha =3D beta =3D 0 > temp_a=2C temp_b =3D calculate(...) > alpha +=3D temp_a > beta +=3D temp_b >=20 > Is there a better way to do this without holding each temporary > result before using it to increment? >=20 > -tkc >=20 >=20 > --=20 > http://mail.python.org/mailman/listinfo/python-list = --_29d5b315-b00d-41fb-a293-16fdc3365797_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
alpha=2C beta =3D (1 if some_cal= culation(params) else 0=2C 1 if other_calculation(params) else 0)

>=3B Date: Fri=2C 7 Jun 2013 21:32:39 -0500
>=3B From: python.lis= t@tim.thechases.com
>=3B To: python-list@python.org
>=3B Subject:= Idiomatic Python for incrementing pairs
>=3B
>=3B Playing aroun= d=2C I've been trying to figure out the most pythonic way
>=3B of incr= ementing multiple values based on the return of a function.
>=3B Somet= hing like
>=3B
>=3B def calculate(params):
>=3B a =3D= b =3D 0
>=3B if some_calculation(params):
>=3B a +=3D = 1
>=3B if other_calculation(params):
>=3B b +=3D 1
&= gt=3B return (a=2C b)
>=3B
>=3B alpha =3D beta =3D 0
&g= t=3B temp_a=2C temp_b =3D calculate(...)
>=3B alpha +=3D temp_a>=3B beta +=3D temp_b
>=3B
>=3B Is there a better way to do= this without holding each temporary
>=3B result before using it to in= crement?
>=3B
>=3B -tkc
>=3B
>=3B
>=3B --
&= gt=3B http://mail.python.org/mailman/listinfo/python-list
= = --_29d5b315-b00d-41fb-a293-16fdc3365797_--