def str2pyval(string):
 try:
  return ast.literal_eval(string)
 except (ValueError, SyntaxError):
  return _PYVALS.get(string, string)

def str2pyval ( string ) : try : return ast . literal_eval ( string ) except ( ValueError , SyntaxError ) : return _PYVALS . get ( string , string )
this function takes a string and returns a python object .