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

Chris Angelico rosuav at gmail.com
Mon Apr 16 15:52:38 EDT 2018


On Tue, Apr 17, 2018 at 5:42 AM, Mikhail V <mikhailwas at gmail.com> wrote:
> On Mon, Apr 16, 2018 at 8:42 PM, Chris Angelico <rosuav at gmail.com> wrote:
>> On Mon, Apr 16, 2018 at 11:05 PM, Mikhail V <mikhailwas at gmail.com> 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.
>
>
> As I initially said, I just don't find this choice list fair.
> and it should be:
>
> 1) "target = expr"  (which would be first intuitive idea from user's PoV,
> and if can't be made then explained to Python people why not)

That one is dealt with in the PEP. It is not an option.

> 2) "target := expr" (as probably best close alternative)

Yep, got that one.

> 3) "target ? expr" (where ? is some other word/character -  IIRC
>   "target from expr" was proposed once)

... which isn't specific enough to be a front-runner option.

> That's it.
> But well, if I compare to your choice list - there is ":=" option you
> have as well :)

Yes. I'm not sure what's unfair about the options I've given there.

ChrisA


More information about the Python-ideas mailing list