[Python-ideas] collections.Counter should implement __mul__, __rmul__
Raymond Hettinger
raymond.hettinger at gmail.com
Wed Apr 18 11:33:03 EDT 2018
> On Apr 16, 2018, at 5:43 PM, Tim Peters <tim.peters at gmail.com> wrote:
>
> BTW, if _`Counter * scalar` is added, we should think more about
> oddball cases. While everyone knows what _they_ mean by "scalar",
> Python doesn't.
I've started working on an implementation and several choices arise:
1) Reject scalar with a TypeError if scalar is a Counter
2) Reject scalar with a TypeError if scalar is a Mapping
3) Reject scalar with a TypeError if scalar is a Collection
4) Reject scalar with a TypeError if scalar is Sized (has a __len__ method).
I lean toward rejecting all things Sized because _everyone_ knows that scalars aren't sized ;-)
Raymond
More information about the Python-ideas
mailing list