Recently, I was trying to store and read information from files in Python, and came across a slight problem: I wanted to read type information from text files. Type casting
Perhaps this is what you want, it looks into builtin types only:
def gettype(name): t = getattr(__builtins__, name) if isinstance(t, type): return t raise ValueError(name)