What is the best way to create a Python object when you have the class implementaion stored in a string?
<p>What is the best way to dynamically create a Python object instance when all you have is the Python class saved as a string? </p>

<p>For background, I am working in the Google Application Engine environment and I want to be able to load classes dynamically from a string version of the class. </p>

<pre><code>problem = “1,2,3,4,5”

solvertext1 = “””class solver:
  def solve(self, problemstring):
   return len(problemstring) “””

solvertext2 = “””class solver:
  def solve(self, problemstring):
   return problemstring[0] “””

solver = #The solution code here (solvertext1)
answer = solver.solve(problem) #answer should equal 9

solver = #The solution code here (solvertext2) 
answer = solver.solve(problem) # answer should equal 1
</code></pre>
