How to use the autocorrect.utils.Zero function in autocorrect

To help you get started, we’ve selected a few autocorrect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phatpiglet / autocorrect / autocorrect / utils.py View on Github external
def get(self, key):
        try:
            return super(Zero, self).__getitem__(key)
        except KeyError:
            return 0
github phatpiglet / autocorrect / autocorrect / utils.py View on Github external
except TypeError:
        return ''.join(chain.from_iterable(args))

class Zero(dict):
    """dict with a zero default"""

    def __getitem__(self, key):
        return self.get(key)

    def get(self, key):
        try:
            return super(Zero, self).__getitem__(key)
        except KeyError:
            return 0

zero_default_dict = Zero