myList = ['100', 'sin(x)', '0', '1']
I read these strings from a text file. I now want to execute the function call sin(x) from that string -- I want this to be a general interpretation of the string for any function expression.
I have tried the following with no success.
myList[1].replace("'", "")
I guess what I am asking is how to pull a string from a list and use it's 'raw text' so to speak.
The end goal is to get this function, where myList[1] should turn to sin(x)
from math import sin
def f(x):
return myList[1]
Thus f(x) will give the computed value of sin(x) from this list.