
Dec. 5, 2009
9:13 p.m.
I prefer (b). The problem with requiring `start` for sequences of non- numerical objects is that you now have to go out and create a "zero object" of the same type as your other objects. The object class might not even have a concept of a "zero object".
If the objects can be summed, shouldn't there also be a zero object?
Use a single univeral zero object that works for everything. Here's an example from my earlier post:
class Zero: ... 'universal zero for addition' ... def __add__(self, other): ... return other ... def __radd__(self, other): ... return other ... Zero() + 'xyz' 'xyz' sum(['xyz', 'pdq'], Zero()) 'xyzpdq'
Raymond