code: def apply_dict_default(dictionary, arg, default):
      '''
      Used to avoid generating a defaultdict object, or assigning defaults to a dict-like object
  
      apply_dict_default({}, 'test', list)
      # => {'test': []}
  
      apply_dict_default({'test': 'ok'}, 'test', list)
      # => {'test': 'ok'}
      '''
      if arg not in dictionary:
          if hasattr(default, '__call__'):
              # Don't try/catch because the method could raise a TypeError and we'd hide it
              default = restrict_args(default, arg)
          dictionary[arg] = default
      return dictionarf apply_dict_default(dictionary, arg, default):
      '''
      Used to avoid generating a defaultdict object, or assigning defaults to a dict-like object
  
      apply_dict_default({}, 'test', list)
      # => {'test': []}
  
      apply_dict_default({'test': 'ok'}, 'test', list)
      # => {'test': 'ok'}
      '''
      if arg not in dictionary:
          if hasattr(default, '__call__'):
              # Don't try/catch because the method could raise a TypeError and we'd hide it
              default = restrict_args(default, arg)
          dictionary[arg] = default
      return dictionary
docs: Used to avoid generating a defaultdict object, or assigning defaults to a dict-like object
  
      apply_dict_default({}, 'test', list)
      # => {'test': []}
  
      apply_dict_default({'test': 'ok'}, 'test', list)
      # => {'test': 'ok'}