Returns new bag of same type multiplied by factor. >>> d = {1: 2, 2: 4, 3: -9} >>> IntegerBag(d) * -1 {1: -2, 2: -4, 3: 9} >>> Bag(d) * -1 {}
(self, factor)
| 255 | return self |
| 256 | |
| 257 | def __mul__(self, factor): |
| 258 | """Returns new bag of same type multiplied by factor. |
| 259 | |
| 260 | >>> d = {1: 2, 2: 4, 3: -9} |
| 261 | >>> IntegerBag(d) * -1 |
| 262 | {1: -2, 2: -4, 3: 9} |
| 263 | >>> Bag(d) * -1 |
| 264 | {} |
| 265 | """ |
| 266 | #XXX should perhaps use explicit IntBag in case derived class needs parameters -- or use copy()??? |
| 267 | return self.__class__(self).__imul__(factor) |
| 268 | |
| 269 | def _size(self): |
| 270 | """Returns sum of absolute value of item counts in bag. |