alpha, beta = (1 if some_calculation(params) else 0, 1 if other_calculation(params) else 0)
> Date: Fri, 7 Jun 2013 21:32:39 -0500 > From: python.l...@tim.thechases.com > To: python-list@python.org > Subject: Idiomatic Python for incrementing pairs > > 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 > > > -- > http://mail.python.org/mailman/listinfo/python-list
-- http://mail.python.org/mailman/listinfo/python-list