[Python-ideas] Dict joining using + and +=

Brett Cannon brett at python.org
Mon Mar 4 20:54:25 EST 2019


On Mon, Mar 4, 2019 at 1:29 PM Neil Girdhar <mistersheik at gmail.com> wrote:

> On Mon, Mar 4, 2019 at 3:58 PM Christopher Barker <pythonchb at gmail.com>
> wrote:
> >
> >
> >
> > On Mon, Mar 4, 2019 at 12:41 PM Guido van Rossum <guido at python.org>
> wrote:
> >>
> >> Honestly I would rather withdraw the subtraction operators than reopen
> the discussion about making dict more like set.
>
> I think that's unfortunate.
> >
> >
> > +1
> >
> > I think the "dicts are like more-featured" sets is a math-geek
> perspective, and unlikely to make things more clear for the bulk of users.
> And may make it less clear.
>
> I'd say reddit has some pretty "common users", and they're having a
> discussion of this right now
> (
> https://www.reddit.com/r/Python/comments/ax4zzb/pep_584_add_and_operators_to_the_builtin_dict/
> ).
> The most popular comment is how it should be |.
>
> Anyway, I think that following the mathematical metaphors tends to
> make things more intuitive in the long run.


Only if you know the mathematical metaphors. ;)


>   Python is an adventure.
> You learn it for years and then it all makes sense.  If dict uses +,
> yes, new users might find that sooner than |.  However, when they
> learn set union, I think they will wonder why it's not consistent with
> dict union.
>

Not to me. I barely remember that | is supported for sets, but I sure know
about + and lists (and strings, etc.) and I'm willing to bet the vast
majority of folks are the some; addition is much more widely known than set
theory.


>
> The PEP's main justification for + is that it matches Counter, but
> counter is adding the values whereas | doesn't touch the values.   I
> think it would be good to at least make a list of pros and cons of
> each proposed syntax.
>

I suspect Steven will add more details to a Rejected Ideas section.


>
> > We need to be careful -- there are a lot more math geeks on this list
> than in the general Python coding population.
> >
> > Simply adding "+" is a non-critical nice to have, but it seems unlikely
> to really confuse anyone.
>

I agree with Chris.

-Brett


> >
> > -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 at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190304/ef81091a/attachment.html>


More information about the Python-ideas mailing list