Accessing a class instance's attributes using user input
问题 So I have this code: class vehicle(object): def __init__(self): self.age = 6 self.make = 8 self.colour = 'colour' self.cost = 'cost' class car(vehicle): def __init__(self): vehicle.__init__(self) self.type = 'car' car1 = car() print car1.make, car1.colour, car1.cost, car1.type, car1.age n = raw_input() dic = {'name' : n} dic['name'] = car() print dic['name'].make In the last bit, I was able to resolve a previous issue I had: Creating an instance of the car class with its name being one that