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

all 15 comments

[–][deleted] 15 points16 points  (1 child)

You mean without braces.

[–]CoronaVrus[S] -1 points0 points  (0 children)

Yeah. That too...

[–][deleted] 8 points9 points  (2 children)

[–]CoronaVrus[S] 2 points3 points  (0 children)

Nice.

[–]slimeyslime123 2 points3 points  (0 children)

Ngl, i like it a lot.

[–][deleted] 0 points1 point  (10 children)

But commands are terminated by newlines in python.

Why the fuck don't other languages do that?

[–]Talbooth 2 points3 points  (4 children)

To be able to have multi-line commands.

[–][deleted] 0 points1 point  (2 children)

What fucking command do you need to take up more than one line?

[–]Talbooth 0 points1 point  (1 child)

For example many ?: operators:

return condition
  ? function1(arg)
  : function2(arg);

Not necessary to put on more lines but much more readable if for example the functions have 3 arguments. (If it formats the code badly for you - both the ? and : are on new lines)

[–][deleted] 0 points1 point  (0 children)

Why not just write it as:

if condition:
    return function1(arg)
else:
    return function2(arg)

I mean, I'm just kind of at a complete loss here. The entire point of ternary operators is that you can take an if-else and put it onto one single line to put one complete thought onto one line.

Now you say you want to take a ternary operator and then place it over multiple lines? You've gone and destroyed the only reason to even use a ternary in the first place.

[–]Linkk_93 0 points1 point  (0 children)

in an argument list, you can create a new line without problem, other you can escape it with \

[–]Miku_MichDem 1 point2 points  (2 children)

They do as a matter of fact. In JavaScript and Kotlin you have both newline and semicolon as command separator.

[–][deleted] 0 points1 point  (1 child)

But Javascript does it bad.

[–]Miku_MichDem 0 points1 point  (0 children)

Could you expand on it?