code: def by_value(self, value, default=None):
          
          try:
              return [k for k, v in self.items() if v == value][0]
          except IndexError:
              if default is not None:
                  return default
              raise ValueError('%s' % value)
docs: Returns the key for the given value