Skip to content

Commit

Permalink
Merge pull request #75 from chrisamin/less-heavy-keys
Browse files Browse the repository at this point in the history
Add __nonzero__ method to ParsingDict
  • Loading branch information
astrikos committed Feb 12, 2016
2 parents 67c00be + 6762e5c commit 893f7f5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ripe/atlas/sagan/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ def __init__(self, **kwargs):
self._on_malformation = kwargs.pop("on_malformation", self.ACTION_WARN)
self.is_malformed = False

def __nonzero__(self):
# If we don't define this, Python ends up calling keys()
# via __len__() whenever we evaluate the object as a bool.
return True

def __len__(self):
return len(self.keys())

Expand Down

0 comments on commit 893f7f5

Please sign in to comment.