I know this is an old question, but I think found a very simple answer, in case anybody needs it.
If you put string quotes inside your string ("'hello'"), ast_literaleval() will understand it perfectly.
You can use a simple function:
def doubleStringify(a):
b = "\'" + a + "\'"
return b
Or probably more suitable for this example:
def perfectEval(anonstring):
try:
ev = ast.literal_eval(anonstring)
return ev
except ValueError:
corrected = "\'" + anonstring + "\'"
ev = ast.literal_eval(corrected)
return ev