[Python-ideas] collections.Counter should implement __mul__, __rmul__
Chris Angelico
rosuav at gmail.com
Sun Apr 15 23:42:47 EDT 2018
On Mon, Apr 16, 2018 at 1:39 PM, Raymond Hettinger
<raymond.hettinger at gmail.com> wrote:
>
> So, the API design issue that confronts us is that it would be a bit weird and disorienting for the arithmetic operators to have two different signatures:
>
> <counter> += <counter>
> <counter> -= <counter>
> <counter> *= <scalar>
> <counter> /= <scalar>
>
This needn't be a blocker. Strings can be added to strings, and
strings can be multiplied by integers. If it's of practical value to
multiply a Counter by a number, by all means do it.
ChrisA
More information about the Python-ideas
mailing list