T
Tim Chase
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
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