I would like tuple (foo, bar)
where
foo = 1
bar = 2
be converted to,
foo_dict = {'foo' : foo, 'bar' : bar}
Is there an easy way to do it?
Update:
I see that my original post is quite misleading. So, considering foo
and bar
are local variables within a function scope. I'd like them to be saved to a global dictionary where the keys are their variable names.
Re-update:
Thanks everyone for the attention. I was using ipywidgets.interact
to tune some parameters (passed as value), however I would like to save them globally, say in a dictionary. That's why the question comes in. Maybe for downvoters there may seem pointless to do such conversion, but do please share some hints for solve my needs pythonically.