Python types default to being truthy when cast to bool, so casting line.Value to bool always returns True. Add a line.Value.__bool__() operator to map the line value to bool as one would intuitively expect, so ACTIVE is True and INACTIVE is False. Signed-off-by: Kent Gibson <warthog618@xxxxxxxxx> --- bindings/python/gpiod/line.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bindings/python/gpiod/line.py b/bindings/python/gpiod/line.py index 1cc512f..d088fb4 100644 --- a/bindings/python/gpiod/line.py +++ b/bindings/python/gpiod/line.py @@ -14,6 +14,9 @@ class Value(Enum): INACTIVE = _ext.VALUE_INACTIVE ACTIVE = _ext.VALUE_ACTIVE + def __bool__(self): + return self == self.ACTIVE + class Direction(Enum): """Direction settings.""" -- 2.39.2