title: Is it possible to dynamic instantiate a class written in a string without the need to write it to a file?
body: <p>How can I instantiate the class stored in the raw string <code>my_class</code> <a href="https://stackoverflow.com/questions/4821104/dynamic-instantiation-from-string-name-of-a-class-in-dynamically-imported-module">without having to save this string into a file first</a>?</p>
  
  <pre><code>my_class = r'''class A:
      def print(self):
          print('Hello World')
      '''
  
  my_class_object = string_to_class()
  
  my_class_object.print()
  </code></pre>
  
  <p>In the code above, I'm looking for an implementation of the function <code>string_to_class()</code> that returns an object of the class inside <code>my_class</code>. </p>
  
  <p>The expected output of the code above is <code>Hello World</code>.</p>