EDIT: i'll never understand people using such functions instead of doing it yourself, and catching everything that can go wrong beforehand
What's wrong with doing it yourself instead?
It's the age old discussion of statements vs expressions, which exists since LISP was created. An if-then-else expression like the python one:
x = TrueValue if Condition else FalseValue
is a single expression, meaning it is one "line" that results in a value.
The if-then-else statement:
if Condition then x := TrueValue else x := FalseValue;
Is a composite of multiple statments:
if Condition then
x := TrueValue // True assignment statement
else
x := FalseValue; // False Assignment statement
There are of course some differences that are easy to spot. For example renaming the variable x requires one change in the expression while 2 changes in the statement. On the other hand in the if-then-else statment you can use non-expressions:
if EOF(file) then
x := '';
else
ReadLn(file, x); // not an expression, but a statement
which is simply not possible for an expression.
Another thing, which might not be so important for such a very simple case, but with more complex expressions/statements is that for expressions x will always be assigned a value, while in the statement case, you could forgett the else case, or even forgett doing the assignment in the else case:
if Condition then
x := Value;
// if condition is false x is undefined
So an if-then-else expression guarantees that the variable will be assigned a value, no matter what, while in the statement case, you need to hope that the programmer that wrote it did not make a mistake, forgott to add the else case, mistyped the variable name, etc.
It also gives you a visual hint on what is happening. The first thing you see with the expression is "x :=" so you know that after this line x will have a value. With the statement the first line is "if condition" so you need to look into both the if and else case to figure out what is happening here. So this also makes it easier to understand what the code is actually doing
Then going a step further from the example at hand, expressions can be used in places where statements cant, e.g. as function parameter:
While for statements, you need to create a temporary variable to evaluate the result in:
if n>0 then
tmp := d/n
else
tmp := 0;
func(tmp);
or create two calls to the function
if n>0 then
func(d/n)
else
func(0);
But now if anything about the function changes, you need to update two places (and have the chance to forgett to update about 2 places and therefore introduce bugs)
Lastly, this is a bit of a soft point, as this is of course highly dependent on the circumstances, expressions have a somewhat limit on their possible complexity. After all, everything needs to fit into a single expression. And this forces the programmer to write more concisely. This is why programs written in expression based languages, like the aforementioned LISP tend to be much smaller than their statement based counterparts (the ballpark numbers that float around academic literature are usually a factor 10-20 less code for the same functionality). And this keeps your code better maintainable.
Generally it is simply less typing you have to do:
x := TrueVal if Condtion else FalseVal; // python syntax
// vs
if Condition then x := TrueVal else x := FalseVal; // 2 times x := instead of only one
So I think that when you can use expressions, you should. It helps to avoid errors by always being well defined and helps to write more concise code.