I have the following string that I’m trying to parse into a dict of k,v
foo = “abc=foo.bazz; defg=6cab; rando=random; token=foobar”
I can achieve this with some really ugly code
foo_dict = {}
bar = foo.split(';')
for item in bar:
x = item.split('=')
foo_dict[x[0]] = x[1]
I’d much prefer this be a simple 1 line list comprehension.
What about using urlparse module:
Not sure if you wanted those blank values in keys or not, but obviously easy to clean.