From: Thang D. N. <tha...@de...> - 2024-04-25 01:06:40
|
Hi Thien, It's better if other operators can be applied, e.i, <, >, .... B.R/Thang -----Original Message----- From: Thien Minh Huynh <thi...@de...> Sent: Tuesday, April 23, 2024 10:45 AM To: Thang Duc Nguyen <tha...@de...>; Dat Tran Quoc Phan <dat...@de...> Cc: ope...@li...; Thien Minh Huynh <thi...@de...> Subject: [PATCH 1/1] pyosaf: Allow SaStringT compare with str by default [#3351] SaStringT class is introduced in previous commit support python3. Default SaStringT cannot compare with other type. This commit is to allow compare with str class if without casting --- python/pyosaf/saAis.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/pyosaf/saAis.py b/python/pyosaf/saAis.py index 912523e69..d890c6a27 100644 --- a/python/pyosaf/saAis.py +++ b/python/pyosaf/saAis.py @@ -53,6 +53,16 @@ if PY3: return self.value.decode('utf-8') else: return self.__repr__() + + def __eq__(self, other): + if isinstance(other, str): + return str(self).__eq__(other) + return super().__eq__(other) + + def __ne__(self, other): + if isinstance(other, str): + return str(self).__ne__(other) + return super().__ne__(other) else: SaStringT = ctypes.c_char_p -- 2.43.0 |