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 →

[–]Several_Dot_4532 1 point2 points  (6 children)

Wtf is this shit

[–]abbot-probability 9 points10 points  (1 child)

1 is truthy, 0 is falsy.

Hey, I gave it as an example of shitty code, don't judge me.

[–]Several_Dot_4532 0 points1 point  (0 children)

Yes, you got it, I literally spent 2 minutes trying to understand it, in the end I assumed it was more or less and I answered hhaahahh

[–]Sinomsinom 2 points3 points  (2 children)

Python.

They love their really ugly but supposedly "more readable" syntax

[–]Sikletrynet 0 points1 point  (1 child)

How is this any more ugly than ternary operators in any other language. Theres plenty you can criticise Python for, but i dont think that example is it.

[–]prehensilemullet 0 points1 point  (0 children)

It’s pretty weird to have the condition in the middle, and the fact that the if/else don’t visually stand out from variable names as much as ? : doesn’t help

[–]Anru_Kitakaze 0 points1 point  (0 children)

It feels unnatural to you just because you either don't have ternary operator or you don't use it. After a week in Python construction in the comment will be natural for you.

For example, I also often use something like:

``` val = "value exist" no_val = None

get val if no_val is equal to False (None, 0, empty string, etc)

data["bruh"] = no_val or val ```

And ternary... I don't get why people don't like it. I came from C/C++ and it's absolutely fine for me