Content deleted Content added
→Python: the if-then-else expression only exists as of Python 2.5. Mention this, and offer an alternative that always works. |
→Python: adapt the names used in the alternative solution to match the ones in the other example |
||
Line 62:
<source lang="python">value_when_true if condition else value_when_false</source>
This feature is not available for Python versions prior to 2.5, however. The [http://www.python.org/doc/faq/programming/#is-there-an-equivalent-of-c-s-ternary-operator Python programming FAQ] mentions several possible workarounds for these versions, with varying degrees of simplicity versus semantic exactness (for example, regarding the [[short-circuit evaluation]] property of ?:). The most complete alternative, that has all the same properties as ?: and still works in Python versions prior to 2.5, would be:
<source lang="python">(
===Result type===
|