On Thu, Oct 17, 2019 at 5:33 AM Steven D'Aprano <st...@pearwood.info> wrote:
> On Thu, Oct 17, 2019 at 08:19:13AM -0000, Steve Jorgensen wrote: > > > Why the need for strictness of type for the operator? I get that it's > > analogous with the behavior for `list`, but I guess I'm also not sure > > why that should be strict. > > (1) Follow the precedent of existing operators. > > (2) It is easier to relax restrictions later, than to add restrictions > if the original behaviour turned out to be a mistake And it's a good idea :-) My first thought was why? I like Dynamic tuypoing, why not except any mapping? Then I relized that when you write: a_list + a_tuple do you want a list or a tuple back? Yes, you could be clear about the precedence, but maybe that wouldn't be obvious to everuyone. So better to require people to be explicit: a_list + list(a_tuple) or some such. Same applies to Mappings. ANd one more note: " Open questions Should these operators be part of the ABC Mapping API? ' Absolutely! having the built in mapping NOT be the same as the Mapping API seems like a really bad idea. The whole point of having all those ABCs is so people can write type-independent code. If I write a function that requires a Mapping, and I only test it with dicts, and I use + -- then it will fail when used with another Mapping object. I guess in short -- we should not have key ABCs with no implementation! -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/R5P67TMNOMY3FTTEVPLRAQKV6KWFUZI4/ Code of Conduct: http://python.org/psf/codeofconduct/