I have a method, which takes a lot arguments as input. Something like this, but with more args:
foo.add(a=True, b=0, c='z', d=(1, 0, 0), e=2, f='g')
foo.add(a=False, b=3, c='z', d=(1, 0, 2), e=2, f='z')
foo.add(a=True, b=10, c='h', d=(1, 3, 0), e=2, f='2')
I decided to make a dictionary and add each line's args into that. But I can not use it like this:
foo_dict = {
"a": "a=True, b=0, c='z', d=(1, 0, 0), e=2, f='g'",
"b": "a=False, b=3, c='z', d=(1, 0, 2), e=2, f='z'",
"c": "a=True, b=10, c='h', d=(1, 3, 0), e=2, f='2'",
}
foo.add(foo_dict["a"])
foo.add(foo_dict["b"])
foo.add(foo_dict["c"])
What is the best way to pass the args from another variable and not getting error?
dict, you could use a double splat (unpacking).foo.add(**foo_dict["a"])