Idiomatic Python for incrementing pairs
Tim Chase
python.list at tim.thechases.com
Fri Jun 7 22:32:39 EDT 2013
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
More information about the Python-list
mailing list