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

Steven D'Aprano steve at pearwood.info
Wed Nov 16 19:06:55 EST 2016


On Wed, Nov 16, 2016 at 11:24:01PM +0100, Mikhail V wrote:

[...]
> My only fault is that I choose wrong name
> for the keyword and naively supposed that it will not cause big
> misunderstanding.
> 
> Ok? So lets say I made a typo and lets take other keyword, it is not
> so important in this case, which one.

It doesn't matter what keyword you come up with, you still have the 
problem that this idea introduces a new keyword. New keywords always 
break backwards compatibility, which means there has to be a good reason 
to do it.

We could make up a random keyword, XusBeooSwqxy3nf7TRx say, and expect 
that probably nobody in the world has ever used that in their code 
before. But it would be hard for people to remember and spell correctly, 
and that goes against the idea that keywords should be meaningful.

Any meaningful name you pick as a keyword will probably clash with 
somebody's code, which means you will break their working program by 
introducing a new keyword.

We take our responsibility seriously: we try very hard to not break 
people's code when they upgrade, so there has to be a really, really 
good reason before new keywords are introduced.

If this was, say, Python 2.2 or so, and you proposed a new keyword:

    really_long_variable_name = KEYWORD + 1

then it might be treated a bit more seriously. But the first question 
we'd ask is, what do other languages do? Python rarely invents new 
programming ideas itself, but it does copy good ideas from other 
languages.

And of course, the most obvious answer is:

    Most C-based languages have a += augmented assignment
    symbol, which avoids the need for a new keyword:

    really_long_variable_name += 1

Now that we have symbols for augmented assignment, there's *zero* chance 
that we will remove them, and very little chance that we'll introduce a 
parallel syntax for doing the same thing by keyword.

To get an idea of the standard we require before adding major new syntax 
or keywords, you should read the historical PEPs:

https://www.python.org/dev/peps/

You don't have to write up a full PEP before proposing an idea here, but 
if the idea involves a large change (especially a new keyword) it almost 
certainly will require a PEP. But either way, reading the PEPs will give 
you an idea of what proposals are likely to be accepted, which are 
likely to be rejected, and which are still open for discussion, as well 
as the sorts of objections you are likely to receive.



-- 
Steve


More information about the Python-ideas mailing list