Perhaps I don't understand the alternative?
Normal Python:
a = 1 if b else 2
The thing you are saying:
a = if b 1 else 2
?
Conversation
Literally like when you have, with your normal syntax:
if <b>:
x
else:
y
you should be able to just assign that to a variable:
a =
if <b>:
x
else:
y
This is how reasonable languages work. Better if it's not whitespace-sensitive so you can throw this on a line
5
1
16
this feels less like a complaint about Python and more like a complaint about statement-oriented languages, which I think includes nearly all imperative languages. but most C descendants do the b ? x : y syntax, which I think is *more* confusing than Python's solution.
2
8
(I do think that expression-oriented languages are better because of things like this, but they are definitely less popular in terms of total number of users and so are probably not what most people would consider "normal")
1
2
Oh, yes, it absolutely is a complaint against statement-oriented languages
3
5
But if you aren't going to make your language reasonable, at least expose some syntax that lets you fake it, not fundamentally new syntax
1
3
yeah I agree, it's weird that it's just, like, a totally different syntax. benevolent dictator's gonna dictate, I guess 🤷🏻♂️
1
This whole thread is bonkers to me. It's like "why is this thing written like words and not written all sideways?" and I'm just over here like "wait, aren't words better?"
2
1
Literally you need a distinct syntax to assign the result of if/else to a variable, that isn't extremely weird to you?
1
Both are normal English, so not really.
"If I'm hungry, I'll eat, otherwise I won't"
"I'll eat if I'm hungry, otherwise, I won't."
2
1
As you kind of hint at with your use of ‘otherwise’, ‘if/else’ is kind of a weird way to express a conditional in English anyway. Here's an interesting presentation that tries to track down where it came from:
I guess my point is that natural language usage in programming languages is important to take into account and leverage if possible, but don't think we necessarily need to be beholden to it as much as we might think?
1



