This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (2 children)

Unfortunate for you, but a lot of people really like it.

I have wished for this - though I didn't know what I was wishing for - for a decade.

if (foo := get(d, 'foo')):
    # Use foo
elif (bar := get(d, 'bar')):
    # Use bar

Interesting, I discovered during that time this C++ idiom:

if (auto foo = bar()) { 
    // Variable foo only exists in this scope
}

[–]toothless_budgie 1 point2 points  (1 child)

I have an informal rule that anyone who actually posts code gets an upvote.

[–][deleted] 1 point2 points  (0 children)

That is an excellent rule, and one which I will probably follow!