Vedran Čačić <[email protected]> added the comment:
Now I had the opportunity to play with the walrus (as it is affectionately
called in some parts of the community), I have to ask you for a reconsideration
of one part of PEP 572.
Unparenthesized assignment expressions are prohibited at the top level of
an expression statement. This rule is included to simplify the choice for the
user between an assignment statement and an assignment expression -- there is
no syntactic position where both are valid.
Correct, but the motivation rests on a wrong premise, that the effect is the
same. In one very important case, it is not: in REPL (including things like
Jupyter notebooks), the values of expressions are printed (if not None). I
really hoped that the walrus would enable me to both assign and see the result
at once. (Now it does, but I have to parenthesize, and that just looks ugly.)
More than half of the cells in my Jupyter notebooks are of the form
name = some.complicated.method(of={some: arguments})
name
another_name = another.method(name, [additional, arguments])
another_name
And while I understand why I had to write them like this before PEP 572, now I
really think they would look much tidier as
name := some.complicated.method(of={some: arguments})
another_name := another.method(name, [additional, arguments])
Please reconsider.
----------
nosy: +veky
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35224>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com