def parse_variable(config, v):
    """Parse a configuration variable from a string that should look like 'key = value'
    and write that value to config[key].

    :param config:  The configuration dict to wich to write the key,value pair
    :param v:       A string of the form 'key = value'
    """
    if '=' not in v:
        raise ValueError(
            'Improper variable specificationi: %s.  Use syntax: key = value.' %
            v)
    key, value = v.split('=', 1)
    key = key.strip()
    if '#' in value:
        value = value.split('#')[0]
    value = value.strip()
    if value[0] in ['{', '[', '(']:
        if value[-1] not in ['}', ']', ')']:
            raise ValueError('List symbol %s not properly matched' % value[0])
        values = value[1:-1].split(',')
        values = [v.strip() for v in values]
    else:
        values = value.split()
    if len(values) == 1:
        config[key] = values[0]
    else:
        config[key] = values
