Steven D'Aprano wrote: > On Sat, 06 Sep 2008 00:33:25 -0400, Manu Hack wrote: > >> Actually it's even more natural to state sum([x]) = x, and this way you >> can never conclude that sum([]) = 0 from there. > > But what you can say is that for any list L, sum(L) = sum(L + [0]). > > Therefore sum([]) = sum([] +[0]) = 0
Yep. The way it is preserves the distributive property sum(a+b) = sum(a) + sum(b) This would matter in cases like (untested code..) suvsales = sum (sum (s.price for s in d.sales if s.class='suv') for d in districts) Mel. -- http://mail.python.org/mailman/listinfo/python-list