guber@lemmy.blahaj.zone to Lemmy Shitpost@lemmy.world · 28 天前proportional reactionlemmy.blahaj.zoneimagemessage-square45linkfedilinkarrow-up1166arrow-down118
arrow-up1148arrow-down1imageproportional reactionlemmy.blahaj.zoneguber@lemmy.blahaj.zone to Lemmy Shitpost@lemmy.world · 28 天前message-square45linkfedilink
minus-squarefour@lemmy.ziplinkfedilinkEnglisharrow-up1·27 天前What I like about using if and else for that is that you’re already using those keywords for branching in other parts of the code. Though my least favorite is probably Python’s: x = "foo" if y > 5 else "bar" It just seems backwards to me
minus-squarethebestaquaman@lemmy.worldlinkfedilinkarrow-up1·edit-227 天前While Python’s version does feel a bit backwards, it’s at least consistent with how list comprehensions are set up. They can also feel a bit “backwards” imo, especially when they include conditionals.
minus-squarefour@lemmy.ziplinkfedilinkEnglisharrow-up1·27 天前List comprehension is another thing I don’t like about Python :) There’s more of those, but one thing I do like about Python is that I get paid for writing it, so I try not to complain too much
minus-squarekryptonianCodeMonkey@lemmy.worldlinkfedilinkarrow-up3·27 天前I love list comprehension. Best part of the language, imo. To each their own.
minus-squareUnfortunateShort@lemmy.worldlinkfedilinkEnglisharrow-up1·edit-227 天前Because Python wants you to read it like English: x is “foo” if y is greater than 5, else it is “bar”
What I like about using
if
andelse
for that is that you’re already using those keywords for branching in other parts of the code.Though my least favorite is probably Python’s:
x = "foo" if y > 5 else "bar"
It just seems backwards to me
While Python’s version does feel a bit backwards, it’s at least consistent with how list comprehensions are set up. They can also feel a bit “backwards” imo, especially when they include conditionals.
List comprehension is another thing I don’t like about Python :)
There’s more of those, but one thing I do like about Python is that I get paid for writing it, so I try not to complain too much
I love list comprehension. Best part of the language, imo. To each their own.
Because Python wants you to read it like English:
x is “foo” if y is greater than 5, else it is “bar”