Ternary to If Expression¶
Sourcery refactoring id:
Replace boolean ternary with inline if expression.
protocol = is_ssl and "https" or "http"
protocol = "https" if is_ssl else "http"
Prior to Python version 2.5 the best way to create a ternary operator was to use
or together in the before example.
The if expression syntax shows the intent of the code much clearer and so is preferred.