I have several variables, some of which I need to change on a certain condition.
test = 'foo'
a, b, c = None, None, None
if test == 'foo':
a = 1
elif test == 'bar':
b = 2
else:
c = 3
I'd like to use the dict approach described here, but how can I modify it to change multiple variables? I want it to work like this:
options = {'foo': ('a',1), 'bar': ('b',2)}
reassign_variables(options,test, ('c',3))
Or can this not be done without creating a function and hard-coding all of the conditions in separately?