Personally no I don;t think it should be a comprehension. LCs are for building lists, although they sometimes are abused for other things, but you do not appear to be building a list per se. The for loop is clearer IMHO.
> Here's my code: > -------------------- > class Water: > def __init__(self, WaterMass, WaterTemperature): > self.mass = WaterMass > self.temperature = WaterTemperature > def __repr__(self): > return ("%.2f, %.2f" % (self.mass, self.temperature)) > > def CombineWater(WaterList): > totalmass=0 > numerator = 0; denominator = 0 > for WaterObject in WaterList: > totalmass += WaterObject.mass > numerator += WaterObject.mass * WaterObject.temperature > return Water(totalmass, numerator/totalmass) Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor