def str_to_list(string, key_name=""):
    """Evaluates a string as a list. Checks if border characters are
    '[' and ']', to avoid bad typing.

    key_name : string (optional)
        Name of the parameter. Useful for error message.
    """
    if string[0] == '[' and string[-1] == ']':
        return list(eval(string))
    else:
        raise ValueError("Hey, bad parameter or list of parameters"
                         " in {} = {}".format(key_name,
                                              string))