def toList ( variable , types = ( basestring , int , float , ) ) : if isinstance ( variable , types ) : return [ variable ] else : return variable
store type of a variable in a list python
Converts a variable of type string int float to a list containing the variable as the only element .
def toList(variable, types=(basestring, int, float, )):
    """Converts a variable of type string, int, float to a list, containing the
    variable as the only element.

    :param variable: any python object
    :type variable: (str, int, float, others)

    :returns: [variable] or variable
    """
    if isinstance(variable, types):
        return [variable]
    else:
        return variable