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

Thautwarm Zhao yaoxiansamma at gmail.com
Mon Apr 16 23:09:07 EDT 2018


 > We have ways of cheating a bit if we want to reinterpret the semantics
> of something that nevertheless parses cleanly - while the parser is
> limited to single token lookahead, it's straightforward for the
> subsequent code generation stage to look a single level down in the
> parse tree and see that the code that parsed as "with expr" is
> actually "with subexpr as target".

It does work, however I think it does sound like a patch, and definitely it
will block us to make other extensions in the future.

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

A more popular convention is to mark `?` as handling boolean variables, so
`target ? expr` could mean `expr if target else target`. Other proposal for
null/boolean checking might need `?`, let's preserve `?` character for
further development.


> 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.

It makes sense, if we don't have a long history in Python programming...
A new keyword would be something very dangerous, because it just causes the
crash of some existed library using the keyword as identifier.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180417/ec22d42f/attachment-0001.html>


More information about the Python-ideas mailing list