I want to create variables inside a function from a dictionary.
Let's say I have a dictionary, bar:
bar = {
'a': 1,
'b': 2,
'c': 3
}
That goes to:
def foo():
a = 1
b = 2
c = 3
I want to make new variables with the variable names as bar's keys (a, b, c), then set the values of the variables to the value of the corresponding key.
So, in the end, it should be similar to:
bar = {
k: v
}
# --->
def foo():
k = v
Is it possible? And if so, how?