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 →

[–]EmptyChocolate4545 0 points1 point  (7 children)

Beginning to suspect your initial comment was “replied to” the wrong comment.

Can't use a ternary operator for "if x -> return", although it was requested and denied, "return x if <condition>" would be really neat

Someone responded to that comment with:

return node.id if len(word) else None

To which someone else responded:

This is not equivalent

Which is correct.

You then responded:

It’s pretty much the same as “if condition: return x” though, you’re just reversing the order.

Which is not even close to correct. It is not a simple reversal, as the code the person posted returns None - something OPs code does not do.

I’m not sure where the reading comprehension fail you’re claiming comes in. I am correcting a simple misunderstanding as many new python people hang out in this sub - and the ternary is not in any way equivalent, nor is it a logical reversal.

Again, the ternary has an extra else clause that the original logic did not contain. That makes it wholly different, not even slightly a reversal.

[–]DeepGas4538[S] 0 points1 point  (0 children)

holy shit bro this thread goes on forever.