is it possible to call a function using a variable as the name for a variable? Example:
def my_method(foo="bar"):
print(foo)
var = "foo='baz'"
my_method(var)
>>> baz
Now, I can't figure out a way to do this kind of thing (substitute the value in a variable for a variable name).
Is this kind of thing possible?
I know there are things you can do that are analogous to this, for instance:
def my_method(foo, bar, baz):
print(foo, bar, baz)
var = ['one','two','three']
my_method(*var)
>>> one two three
But I can't find a uniform, generalized solution to any metaprogramming I might need in python. Is there one? Perhaps the language just isn't capable of a generalized metaprogramming solution.