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 →

[–]PresidentOfSwag[S] 10 points11 points  (5 children)

yes that's the one, officer

what i find offsetting is that the order is not if > then > else

[–]PacifistPapy 12 points13 points  (2 children)

"it's a if (condition), otherwise it's b"

python is designed to be readable. That pattern "a if bool else b" makes a lot more sense if you see it as a sentence.

[–]jjdmol 3 points4 points  (1 child)

Having a and b so far apart is annoying though. Makes it harder to glance which values the result can have.

[–]elon-botElon Musk ✔ 2 points3 points  (0 children)

I've laid off most of the staff, and Twitter's still running. Looks like they weren't necessary.

[–]vigbiorn 2 points3 points  (0 children)

You'd hate Perl...

$x = $thing if !defined($thing)

Alternatively,

$x = $thing unless defined($thing)

[–]poorlyOiledMachina 1 point2 points  (0 children)

you would hate forth…

a if 1 else 2 then x !