[Python-ideas] Technical possibilities for a syntax [was: Reverse assignment operators ...]

Mikhail V mikhailwas at gmail.com
Thu Nov 17 05:16:14 EST 2016


On 17 November 2016 at 10:22, Paul Moore <p.f.moore at gmail.com> wrote:
> On 17 November 2016 at 03:07, Stephen J. Turnbull
> <turnbull.stephen.fw at u.tsukuba.ac.jp> wrote:
>> Paul Moore writes:
>>
>>  > PS Note for anyone who wants to take this off on a wild tangent - my
>>  > above comment is *in the context of Python as it has been defined for
>>  > 20+ years*.
>>
>> Not quite.  Augmented assignment operators were added in Python 2.0
>> according to What's New, and they were quite controversial (== Guido
>> didn't like them) at the time.  In that respect, Mikhail is in good
>> company (perhaps for different reasons).  But Guido did accept them,
>> and they are immoveable at this point in time.
>
> Fair point. My "20+ years" was a rough guess, and wasn't so much
> intended to relate specifically to augmented assignment as to the
> principles involved. Python tends to pick up ideas from other C-like
> languages, and doesn't arbitrarily deviate from common syntax (the
> conditional expression being the most obvious example where we did use
> a different syntax than everyone else).
>
> Paul
>
> PS Whatever the merit of Mikhail's specific proposals, he is prompting
> discussion on the principles behind our rejection of his ideas, and
> that's valuable. So thanks to him for that, at least.

Citation from
http://legacy.python.org/dev/peps/pep-0203/

"""
Expressions of the form

        <x> = <x> <operator> <y>

    are common enough in those languages to make the extra syntax
    worthwhile, and Python does not have significantly fewer of those
    expressions. Quite the opposite, in fact, since in Python you can
    also concatenate lists with a binary operator, something that is
    done quite frequently. Writing the above expression as

        <x> <operator>= <y>

->    __is both more readable__ and less error prone, because it is
    instantly obvious to the reader that it is <x> that is being
    changed, and not <x> that is being replaced by something almost,
    but not quite, entirely unlike <x>.

"""

Aha, sure, if "readable" == "suits C programmers".
And it's surely not, which in some sence also means that it *more*
error prone, since I cannot notice possible error so easy.

(I am not trying to start flame again though, that is *not* my intention)

Mikhail


More information about the Python-ideas mailing list