[Python-ideas] PEP 572: Assignment Expressions (post #4)

Stephen J. Turnbull turnbull.stephen.fw at u.tsukuba.ac.jp
Thu Apr 12 02:39:11 EDT 2018


Nick Coghlan writes:

 > >     # Similar to the boolean 'or' but checking for None specifically
 > >     x = "default" if (eggs := spam().ham) is None else eggs
 > >
 > >     # Even complex expressions can be built up piece by piece
 > >     y = ((eggs := spam()), (cheese := eggs.method()), cheese[eggs])

My immediate take was "this syntax is too ugly to live", but so are
Gila monsters, and I don't understand the virtues that lead Nick and
Guido to take this thread seriously.  So I will just leave that
statement here.  (no vote yet)

More constructively, I found it amusing that the results were stuffed
into generic one-character variables, while the temporaries got actual
words, presumably standing in for mnemonic identifiers.  Besides
moving the examples, that should be fixed if these examples are to be
used at all.  I'm also with Paul (IIRC) who suggested formatting the
second example on multiple lines.

I suggest s/x/filling/ (sandwich) and s/y/omelet/.

Steve


More information about the Python-ideas mailing list