From 1cf61d8bac6ab927fd7f23b3c35e1d463577b951 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Fri, 12 Aug 2022 10:27:15 -0300 Subject: [PATCH] True/false --- hashlist.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hashlist.py b/hashlist.py index 080ca95..e05fe1c 100644 --- a/hashlist.py +++ b/hashlist.py @@ -13,6 +13,9 @@ class E: def __eq__(self, other): return self.internal_list == other.internal_list + def __bool__(self): + return len(self.internal_list) > 0 + content = set() w1 = E([1, 2]) @@ -21,3 +24,9 @@ content.add(w1) content.add(w2) print(content) + +w3 = E([]) +if w3: + print('It is true') +else: + print('It is false')