A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-April/152805.html below:

[Python-Dev] PEP 572: Assignment Expressions

[Python-Dev] PEP 572: Assignment Expressions [Python-Dev] PEP 572: Assignment ExpressionsChristoph Groth christoph at grothesque.org
Fri Apr 20 14:15:04 EDT 2018
Nick Coghlan wrote:

> I also think that if "=" and ":=" both target the same kind of scope,
> there isn't enough new expressiveness introduced by the latter to
> justify the syntactic complexity of adding it.

OK, but then how about introducing assignment expressions with the "="
operator but *requiring* extra parens (similar to how modern C compilers
warn about assignment expressions without parens), e.g.

while (obj = get()):
    process(obj)

The semantics of assignment expressions could be exactly what I proposed
for ":=", i.e. completely consistent with assignment statements.

Assignment statements could be either left as they are or could be
treated as expressions.  That second choice would have consequences for
interactive sessions:

>>> a = 3
3

----------------

The above would bring the benefits of assignment expressions in a
minimally invasive but safe way.  Moreover, it would not feel like
Pascal!  The only downside is that "=" stands out less than ":=" so that
the presence of side-effects would be somewhat less visible.

Christoph
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4