def _sum_costs(costs, source):
 def plus(pi1, pi2):
  assert (pi1.quantity == pi2.quantity)
  return PriceInfo((pi1.price + pi2.price), (pi1.base_price + pi2.base_price), quantity=pi1.quantity)
 zero_price = source.create_price(0)
 zero_pi = PriceInfo(zero_price, zero_price, quantity=1)
 return functools.reduce(plus, (x.price_info for x in costs), zero_pi)

def _sum_costs ( costs , source ) : def plus ( pi1 , pi2 ) : assert ( pi1 . quantity == pi2 . quantity ) return PriceInfo ( ( pi1 . price + pi2 . price ) , ( pi1 . base_price + pi2 . base_price ) , quantity = pi1 . quantity ) zero_price = source . create_price ( 0 ) zero_pi = PriceInfo ( zero_price , zero_price , quantity = 1 ) return functools . reduce ( plus , ( x . price_info for x in costs ) , zero_pi )
sum price info of given costs and return the sum as priceinfo .