[Python-ideas] How we think about change [was: Reverse assignment operators...]

David Mertz mertz at gnosis.cx
Tue Nov 15 22:56:30 EST 2016


The "just see it" isn't likely to go very far.  My impression is that maybe
5% of people find '+=' and friends confusing or bothersome.  Probably 15%
are neutral (including me). And 80% think 'a += 1' is simply MORE readable
and more easily understood than 'a = a+1'. Folks who come from C-family
languages especially like the augmented assignment.

It's very common for the inplace and binary operators to do the same thing.
For those cases,  it really is just syntax sugar. But enough importent
libraries like NumPy make a distinction tray a highly value having
__iadd__() and friends.

On Nov 15, 2016 1:03 PM, "Mikhail V" <mikhailwas at gmail.com> wrote:

> On 15 November 2016 at 14:04, Stephen J. Turnbull
> <turnbull.stephen.fw at u.tsukuba.ac.jp> wrote:
>
> > > Mikhail V writes:
>
> > > But how do you jump to lists already?
>
> > Thus, in explaining this kind of thing it is often useful
> > (YMMV) to "jump" to a different type that supports the same behavior
> > to see how a proposed change can cause inconsistency.
>
> First, thank you for the input, and time spent to clear things here.
>
> I must admit I cannot "jump" for this time. Not only because
> I don't know inner nature of *all* possible implementions and
> cannot analyse them all in coverable amount of time,
> but also because I cannot draw logical connection between
> "appending to a list" and "incrementing an integer value" expressings,
> even if for some reason we want to use same syntax for both.
> Otherwise it would make extremely hard to contribute ideas for
> syntax improvement from not "python-dev" people.
> Of course only if one wants to recieve such ideas.
>
> > > I started an example with integers.  I just want to increment an
> > > integer and I don't want to see any += in my code, it strains
> > > me.
>
> > Just don't use it.
> > If by "my code" you mean "code I might have to read"[1], you're just out
> > of luck, even for the very special case of integers.
>
> I tend to use word *my* since I can carry responsibility only for things
> I know from my experience. I hear often *we* in western political TV shows
> and this sounds not so good for my ears. But it is more of cultural
> thing I think.
> And I must read not only *my own* code of course.
> I personally never use += operators  if I can.
>
> > (1) Guido himself preferred *not* to have augmented assignment way back
> when,
> > but bowed to popular demand.  You are in a tiny minority, opposing the
> > preference of a large and loud majority.  (2) Guido could remove those
> > operators, but it would break a lot of existing code that uses them,
> > and that would not be acceptable.[2]
>
> Good to know that at least this being discussed, but not so good
> that majority wins. As for Python's numbers I personally would without
> hesitation
> remove the += and Co.
> I was jus curious how bad would it "break" things? Currently I cannot run
> my 2.7
> code with 3.x Python, so I need to convert it. Probably not so obvious,
> how to convert the code with numeric operators automatically,
> since there are no type annotations in code...
>
> All in all, the issues of compatibility and majority with habits
> are there, I just think of "python-ideas" merely as discussion about
> possible future syntax improvements, simply because it relates to my
> specialization.
> But I also try to learn the technical part.
>
> To summarize things:
>
> I may be well losing my time explaining why += is bad, that is true.
> It is next to impossible to explain it, unless one can just *see* it.
> But apart from minority/majority, there is only one truth, so I would say,
> if "we" could consider such a slight rearrangement of how we *call* the
> things:
>
> Now I see many people call +=  a "syntactic sugar", and for me it is
> rather a "syntactic defect", so it is something on the opposite.
> One can say it is only opinion, ok, but if at least a pair of people will
> stop writing +=, then I could say, my mission was not a fail.
>
>
> Mikhail
> _______________________________________________
> 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/20161115/da6a8753/attachment-0001.html>


More information about the Python-ideas mailing list