(value)
return 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')
        ValueError: cannot encode objects that are not 2-tuples.

    :rtype: list
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.,
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 .
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')
        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)
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 )