I have a string \"{\'datetime\': datetime.datetime(2010, 11, 21, 0, 56, 58)}\" and I want to convert this to the object it represents. Using ast.literal_
\"{\'datetime\': datetime.datetime(2010, 11, 21, 0, 56, 58)}\"
ast.literal_
Use the language services to compile it into an AST, walk the AST making sure that it contains only whitelisted node sets, then execute it.