Skip to content

Commit

Permalink
Add missing Trie.__bool__ method
Browse files Browse the repository at this point in the history
  • Loading branch information
mina86 committed May 5, 2018
1 parent f2df4da commit 19ae72a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pygtrie.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,8 @@ def __eq__(self, other):
def __ne__(self, other):
return not self.__eq__(other)

def __bool__(self):
return bool(self.value is not _SENTINEL or self.children)

__nonzero__ = __bool__

__bool__ = __nonzero__ = lambda self: bool(
self.value is not _SENTINEL or self.children)
__hash__ = None

def __getstate__(self):
Expand Down Expand Up @@ -535,8 +532,7 @@ def __len__(self):
"""
return sum(1 for _ in self.itervalues())

def __nonzero__(self):
return bool(self._root)
__bool__ = __nonzero__ = lambda self: bool(self._root)

HAS_VALUE = 1
HAS_SUBTRIE = 2
Expand Down

0 comments on commit 19ae72a

Please sign in to comment.