How do I convert a class name to a class constructor ?
Example
Let say we have a method that takes two strings as input, first the output type, and then the value to convert. Here are some example of outputs:
- foo("int", "12") would return 12
- foo("str", "12") would return "12"
- foo("float", "12") would return 12.0
What is the content of foo(), without using pydoc.locate() ?
edit: getattr(sys.modules[name], str) works with new classes, but not with systems classes. Then it's not a valid solution for my problem