Skip to content

Commit

Permalink
GH-11: Implement FuzzyMap behavior for the get method of dict (GH-12
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ArtyomVancyan authored Dec 3, 2022
2 parents dcc6a4d + f934357 commit fdd51ba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fuzzymap/fuzzymap.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def closest_key(self, key):
return matching
return key

def get(self, key, default=None):
"""Invokes the __getitem__ to keep the `FuzzyMap` behavior"""

return self[key] or default

def __missing__(self, key):
return super().get(self.closest_key(key))

Expand Down

0 comments on commit fdd51ba

Please sign in to comment.