On 2006-04-05, Tomi Lindberg <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: > >> def __rmul__(self, num): >> tp = num * [self] >> return reduce(operator.add, tp) >> >> sum3d6 = 3 * D(6) > > One basic question: is there any particular reason not to > use __mul__ instead (that would allow me to use both 3 * > D(6) and D(6) * 3, while __rmul__ raises an AttributeError > with the latter)?
Well 3 * D(6) is similar to the notation used in roleplaying, while D(6) * 3 would make me think of the distribution {3:1, 6:1, 9:1, 12:1, 15:1, 18:} > Difference between the two methods is > slightly unclear to me. I have to look it up myself regularly. But in this case it was more a matter of some intuition that 3 * D(6) was not the same as D(6) * 3. You may have a different intuition. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list