Dice probability problem
Tomi Lindberg
tomi.lindberg.NO_SPAM at pp.inet.fi.invalid
Wed Apr 5 09:59:06 EDT 2006
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)? Difference between the two methods is
slightly unclear to me.
Thanks,
Tomi Lindberg
More information about the Python-list
mailing list