[Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

Chris Angelico rosuav at gmail.com
Mon Apr 16 15:20:34 EDT 2018


On Tue, Apr 17, 2018 at 5:11 AM, Steve Barnes <gadgetsteve at live.co.uk> wrote:
>
>> Here are the three most popular syntax options, and how each would be explained:
>>
>> 1) "target := expr" ==> It's exactly the same as other forms of
>> assignment, only now it's an expression.
>> 2) "expr as name" ==> It's exactly the same as other uses of "as",
>> only now it's just grabbing the preceding expression, not actually
>> doing anything with it
>> 3) "expr -> name" ==> The information went data way.
>>
>> So either you take a parallel from elsewhere in Python syntax, or you
>> take a hopefully-intuitive dataflow mnemonic symbol. Take your pick.
>
> How about "name being expression" - this avoids the already used "as"
> while being searchable, reasonably short and gives a reasonably clear,
> (at least to English speakers), indication of what is going on. It can
> also be typed on an ASCII keyboard without having to have a helper
> program or memorising Unicode codes and can be displayed or printed
> without having to install specialised fonts.
>
> If a postfix notation is considered desirable, either instead or as well
> as "being", then possibly another synonym would suit such as "expression
> stored_as name" or "expression storedas name" (not apologies for the
> awkward name as I personally find it an awkward construction just like
> Reverse Polish).

IMO searchability isn't enough of an advantage to justify creating a
new keyword, which could potentially break people's code. (I don't
think it'll break the stdlib, but it'll almost certainly break at
least some code out there.) New keywords have an extremely high bar to
reach.

ChrisA


More information about the Python-ideas mailing list