This question is similar to the one asked here:
However in my case I have a large dictionary filled with many keys and values, and I will not be able to enumerate each key to implement this solution:
from operator import itemgetter
params = {'a': 1, 'b': 2}
a, b = itemgetter('a', 'b')(params)
In my case:
from operator import itemgetter
params = {'a': 1, 'b': 2 ........... 'y': 25, 'z': 26 }
a, b ..... y, z = itemgetter('a', 'b'.... 'y', 'z')(params)
Is there any way I can unpack and assign each key to it's value, and associate values with variables names after its keys on a large scale?
Please Advise.
# Function
a = 1
b = 2
def foo(z):
return a + b + z
foo(3)
# should return 6