title: Using variable value as dictionary/class name in Python
body: <p>My requirement is to use variable value for referncing class/dictionaries in Python. As a sample example, I have following data :-</p>
  
  <pre><code>class test1:
      pass
  
  class test2:
     pass
  
  test1_dict = {}
  test2_dict = {}
  
  testvariable = "test1"
  </code></pre>
  
  <p>Now I want to check value of <code>testvariable</code> and create an instance of class and append it in dictionary.</p>
  
  <p>e.g.</p>
  
  <pre><code>if testvariable == "test1":
      test1inst = test1()
      test1_dict["test1"] = test1inst
  elif testvariable == "test2":
      test2inst = test2()
      test2_dict["test2"] = test2inst
  </code></pre>
  
  <p>In the above code, I have to explicitly use <code>if/else</code> to check the value of <code>testvariable</code> and do the operations accordingly.</p>
  
  <p>In my real scenario, I could have multiple values of <code>testvariable</code> and there could be multiple places where <code>if/else</code> check would be required. So, is it possible that somehow, I could be able to use the value of <code>testvariable</code> directly to refer dictionary/class instances without using <code>if/else</code>.</p>