This is my current code:
def flag_a_device_status(context, var):
if var == '40D':
context.holder.default_40D = True
elif var= '212F':
context.holder.default_212F = True
elif
elif
else:...
As you can see, var
is a parameter passing from the upstream code, and its value could be "40D", "200F", "212F", etc. And based on its string value, I need to turn on different flag under context.holder
, such as default_40D
, default_212F
, etc.
Is there a better way to handle that in Python? Something as if:
context.holder.default_"var" = True