[Python-ideas] Modern language design survey for "assign and compare" statements

Juancarlo Añez apalala at gmail.com
Sun May 20 14:53:46 EDT 2018

> What would be the benefit of adding the "as child_pid" syntax? The
> full assignment expression syntax completely covers all the jobs that
> you can do with a capturing if statement.
The "as" syntax over "if" and "while" may go in with all the restrictions
and caveats already discussed.

The discussion about the semantics of how ":=" should affect the enclosing
context when used in generators, etc. may continue for as long as it must.

And there are some of us who like the consistency of "us", and would shy
away from ":=".

For example, Should this be valid?

if child_pid := os.fork():


This shouldn't be:

if os.fork() as child_pid:

print(child_pid)  # child_pid is undefined

Juancarlo *Añez*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180520/65bf0def/attachment.html>

More information about the Python-ideas mailing list