I have a python function to which a string is passed as parameter, the parameter may be a string representation of int, array,dictionary or a normal string
for int,array and dictionary its working properly, but if the parameter is a normal string the ast.literal_eval() throws error
import ast # below statements throw error #output_value = ast.literal_eval('someNormalString') #output_value = ast.literal_eval('name1 name2 name3') #below statements work fine output_value = ast.literal_eval('5') output_value = ast.literal_eval('[{"id":"XYZ_GTTC_TYR", "name":"Suction"}]') output_value = ast.literal_eval('["name1","name2"]') print(output_value) is there any way to to handle it if the param is just a normal string?
below is my python function
def func(key): value = ast.literal_eval(value) return value