def string_to_list(my_str, convert=None):
    """
    Convert a string representation of list into list
    :param my_str: a string representation of list, e.g. '[1, 2, 3]'
    :param convert: a function to convert data type of each element, e.g. float
    :return: a list, e.g. [1, 2, 3]
    """
    if len(my_str) == 0:
        return []
    my_list = my_str.strip('][').split(', ')

    if convert is not None:
        my_list = list(map(convert, my_list))
    return my_list