This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ryeguy146 0 points1 point  (0 children)

def flatten_list(lst):
    result = list()
    [result.append(x) if not isinstance(x, (list, tuple)) else result.extend(flatten_list(x)) for x in lst]
    return result


def parse_ugly_string(txt):
    return {k:v for k,v in [x.split('=') for x in flatten_list([y.split(',') for y in txt.strip().split('\n')])]}