def str2dict(dict_string):
    """
    Convert a string of key=value pairs to a dictionary.
    Format is 'KEY=value KEY=other value KEY=and some more values'
    For example: str2dict('key1 = 1 key2 = a b c key3=23.4) returns the dictionary
    {'key1':'1' , 'key2':'a b c', 'key3':'23.4'}
    """
    string_bits = dict_string.split('=')
    keys = [string_bits[0].strip()]
    values = []
    for bits in string_bits[1:-1]:
        pieces = bits.strip().rsplit(' ', 1)
        if len(pieces) == 1:
            key = pieces[0]
            value = 'NONE'
        else:
            key = pieces[1]
            value = pieces[0]
        keys.append(key)
        values.append(value)
    values.append(string_bits[-1])
    return dict(list(zip(keys, values)))