Comment

Comment by luhn

Notably new is the assignment expressions [1]. This was quite controversial and the battle around it caused Guido to step down as BDFL [2].

I personally think it's quite a nifty feature. I often end up writing something along the lines of:

    result = do_something()
    if result:
        do_more(result)
Now that can be expressed as:

    if result := do_something():
        do_more(result)
It definitely has the potential to be abused and reduce readability, but applied well I think it can increase readability.

[1] https://www.python.org/dev/peps/pep-0572/#relative-precedenc... [2] https://mail.python.org/pipermail/python-committers/2018-Jul...

parent luhn 7 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton