Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get(self, key):
try:
return super(Zero, self).__getitem__(key)
except KeyError:
return 0
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