def string_eval(source):
 node = ast.parse(source, '<source>', mode='eval')
 if (not isinstance(node.body, ast.Str)):
  raise ValueError(('%r is not a string literal' % source))
 return node.body.s

def string_eval ( source ) : node = ast . parse ( source , '<source>' , mode = 'eval' ) if ( not isinstance ( node . body , ast . Str ) ) : raise ValueError ( ( '%r is not a string literal' % source ) ) return node . body . s
evaluate a python string literal source .