AppyPrinciplesGetting started
appy.pod Writing ODT templates The « if » expression

In POD for Python 2.x, besides the if statement, POD also proposed an if expression. Indeed, if the things you want to conditionnally include are small enough (a few words for example) and do not span an entire paragraph, you may find more convenient to use the if expression, that was implemented as a function named test being directly available in the POD context as a default function. Here is an example.

The function evaluates the expression passed as first arg. If it evaluates to True, it returns the result of evaluating arg #2. Else, it returns the result of evaluating arg #3. The result is straightforward: no context is needed.

In Python 3, due to the availability of built-in conditional expressions (also sometimes called "if ternary operators"), function test has become useless and has been removed. To achieve in Python 3 the same result as the previous one, you may write the following.