In Python, can I instantiate a class through a dictionary?
shapes = {'1':Square(), '2':Circle(), '3':Triangle()} x = shapes[raw_input()]
I want the user to select from the menu, not the code, if any expressions were input. For example, if the user entered 2, x will then be a new instance of Circle. Is it possible?
python dictionary class
mandroid
source share