[Raymond]
> 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 ;-)

Hard to know how gonzo to get :-(

_Scalar = (Sized, Container, Iterable)): # has __len__, __getitem__, or __iter__
...
if isinstance(arg, _Scalar):
    raise TypeError ...

would also reject things like generator expressions.  But ... those
would blow up anyway, when multiplication was attempted.

So, ya!  Sticking to Sized sounds good :-)
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to