parameters: (value)
return_statement: return list(value)
docstring: Take an object and test to see if it can be represented as a
      dictionary. If it can be, return a list of tuples, e.g.,
  
      ::
  
          >>> to_key_val_list([('key', 'val')])
          [('key', 'val')]
          >>> to_key_val_list({'key': 'val'})
          [('key', 'val')]
          >>> to_key_val_list('string')
          Traceback (most recent call last):
          ...
          ValueError: cannot encode objects that are not 2-tuples
  
      :rtype: list
docstring_summary: Take an object and test to see if it can be represented as a
      dictionary. If it can be, return a list of tuples, e.g.,
docstring_tokens: Take an object and test to see if it can be represented as a dictionary . If it can be return a list of tuples e . g .
function: def to_key_val_list(value):
      """Take an object and test to see if it can be represented as a
      dictionary. If it can be, return a list of tuples, e.g.,
  
      ::
  
          >>> to_key_val_list([('key', 'val')])
          [('key', 'val')]
          >>> to_key_val_list({'key': 'val'})
          [('key', 'val')]
          >>> to_key_val_list('string')
          Traceback (most recent call last):
          ...
          ValueError: cannot encode objects that are not 2-tuples
  
      :rtype: list
      """
      if value is None:
          return None
  
      if isinstance(value, (str, bytes, bool, int)):
          raise ValueError('cannot encode objects that are not 2-tuples')
  
      if isinstance(value, Mapping):
          value = value.items()
  
      return list(value)
function_tokens: def to_key_val_list ( value ) : if value is None : return None if isinstance ( value , ( str , bytes , bool , int ) ) : raise ValueError ( 'cannot encode objects that are not 2-tuples' ) if isinstance ( value , Mapping ) : value = value . items ( ) return list ( value )