title: instantiate python class into C# using the class name as string
body: <p><a href="https://stackoverflow.com/questions/579272/instantiating-a-python-class-in-c-sharp?lq=1">This</a> SO question provides code to create an instance of a python class in C#.</p>
  
  <p>The following code forces to know the python function name in advance. However I need to specify the class name and the function name to be executed by strings.</p>
  
  <pre><code>ScriptEngine engine = Python.CreateEngine();
  ScriptSource source = engine.CreateScriptSourceFromFile("Calculator.py");
  ScriptScope scope = engine.CreateScope();
  source.Execute(scope);
  
  dynamic class_object = scope.GetVariable("Calculator");
  dynamic class_instance = class_object();
  int result = class_instance.add(4, 5);  // I need to call the function by a string
  </code></pre>