consider-ternary-expression / W0160ΒΆ

Message emitted:

Consider rewriting as a ternary expression


Multiple assign statements spread across if/else blocks can be rewritten with a single assignment and ternary expression

Problematic code:

x, y = input(), input()
if x >= y:  # [consider-ternary-expression]
    maximum = x
    maximum = y

Correct code:

x, y = input(), input()
maximum = x if x >= y else y

Configuration file:



This message is emitted by the optional 'consider_ternary_expression' checker, which requires the pylint.extensions.consider_ternary_expression plugin to be loaded.

Created by the consider_ternary_expression checker.