My proposal is to add the terinary operator ?
to python.
How terinary works is:
x = condition ? if true : if false
So it’s basically short for if else
Now since :
has many uses in python we could perhaps use ;
instead
My proposal is to add the terinary operator ?
to python.
How terinary works is:
x = condition ? if true : if false
So it’s basically short for if else
Now since :
has many uses in python we could perhaps use ;
instead
Python already has this. It’s spelled differently: [true outcome] if [condition] else [false outcome]
Here are the docs for the Python conditional expression: 6. Expressions — Python 3.13.2 documentation
See the FAQ: