[Python-ideas] collections.Counter should implement __mul__, __rmul__

Petr Viktorin encukou at gmail.com
Wed Apr 18 12:13:21 EDT 2018



On 04/18/18 17:33, Raymond Hettinger wrote:
> 
> 
>> 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).

Why is Iterable (__iter__) not on the list?

(Apologies if I missed this somewhere in the conversation.)

> 
> I lean toward rejecting all things Sized because _everyone_ knows that scalars aren't sized ;-)
> 
> 
> Raymond
> 
> 
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
> 


More information about the Python-ideas mailing list