I have a class like the following:
class User:
    def __init__(self):
        self.data = []
        self.other_data = []
    def doSomething(self, source):
        // if source = 'other_data' how to access self.other_data
I want to pass a string for the source variable in doSomething and access the class member of the same name.
I have tried getattr which only works on functions (from what I can tell) as well as having User extend dict and using self.__getitem__, but that doesn't work either. What is the best way to do this?
 
     
     
     
    