I've looked everywhere for this but haven't found a suitable answer yet and I don't want to use a dictionary.
How can I convert a string to a variable name? For example I have this call:
object.variable
This variable is defined in the object. However I have a LOT of variables (for a reason) and more to come. It seems stupid to do this:
s = 'variable'
if s == 'variable': object.variable
elif s == 'variable2: object.variable2
etc....
So is there a way to convert a string to a variable name?
dict?gettattr()access to attributes is a good solution.object[s]? (Or do you already use__getitem__for something else?)