News for hackers. Stuff that matters.
Re:PEP 572: Python assignment expressions has been accepted by Dunnorandom on Tuesday July 03, 2018 @04:46PM (#17453490)
The first example would actually be equivalent to something like

    while True:
        bytes = io.get(x)
        if not bytes:
            break
        ...
which I think is objectively less readable.

In the second example, you have an extra call to foo for every element of stuff. If foo(z) is expensive, you'd probably want to write this as

    [bar(x) for x in map(foo, stuff) if x]
instead - which I personally don't mind, but it's arguably not as clear as having the in-line assignment expression.
Re:PEP 572: Python assignment expressions has been accepted by amorousf00p on Tuesday July 03, 2018 @07:56PM (#17454484)
Quibbles and bits. Python is the only language where I write logic and then massage data structures and outputs + design 'cooler' ways to create these for an extra hour -- a week after it is in production.
Re:PEP 572: Python assignment expressions has been accepted by gshulegaard on Tuesday July 03, 2018 @09:28PM (#17454765)
I wasn't really considering the repeated genearation on `io` in the `while` example...so now I see a clear benefit to the syntax. I guess I would say I am now lukewarm about adding this additional operator. It makes at least one logical structure nicer...but I wouldn't have been heartbroken if it wasn't accepted though.
Re:PEP 572: Python assignment expressions has been accepted by roman_g on Wednesday July 04, 2018 @05:13AM (#17456128)
And if foo(z) is consuming a generator somehow (e.g. it's next(g)) then you can't call it twice without side effects.