From e6b92a0fcd9a375672264e741a75dc584bcfc45f Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Mon, 6 Feb 2023 13:31:34 -0500 Subject: Add a __bool__ to BinaryView, Section, and Segment classes --- python/binaryview.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'python/binaryview.py') diff --git a/python/binaryview.py b/python/binaryview.py index be4f28be..eab2373a 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -1316,6 +1316,9 @@ class Segment: def length(self): return int(core.BNSegmentGetLength(self.handle)) + def __bool__(self): + return True + def __eq__(self, other): if not isinstance(other, self.__class__): return NotImplemented @@ -1415,6 +1418,9 @@ class Section: def __len__(self): return self.length + def __bool__(self): + return True + def __eq__(self, other): if not isinstance(other, self.__class__): return NotImplemented @@ -2050,6 +2056,9 @@ class BinaryView: def length(self): return int(core.BNGetViewLength(self.handle)) + def __bool__(self): + return True + def __eq__(self, other): if not isinstance(other, self.__class__): return NotImplemented -- cgit v1.3.1