<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>alpha, beta = (1 if some_calculation(params) else 0, 1 if other_calculation(params) else 0)<br><br><div>> Date: Fri, 7 Jun 2013 21:32:39 -0500<br>> From: python.list@tim.thechases.com<br>> To: python-list@python.org<br>> Subject: Idiomatic Python for incrementing pairs<br>> <br>> Playing around, I've been trying to figure out the most pythonic way<br>> of incrementing multiple values based on the return of a function.<br>> Something like<br>> <br>>   def calculate(params):<br>>     a = b = 0<br>>     if some_calculation(params):<br>>       a += 1<br>>     if other_calculation(params):<br>>       b += 1<br>>     return (a, b)<br>> <br>>   alpha = beta = 0<br>>   temp_a, temp_b = calculate(...)<br>>   alpha += temp_a<br>>   beta += temp_b<br>> <br>> Is there a better way to do this without holding each temporary<br>> result before using it to increment?<br>> <br>> -tkc<br>> <br>> <br>> -- <br>> http://mail.python.org/mailman/listinfo/python-list<br></div>                                          </div></body>
</html>