[Python] A problem for Python hackers: the solution

The solution for the problem I previously posted this month.

Of course, I had eval() in my mind:

>>> import math
>>> x=1.234
>>> s=str(eval("math.sin(x)"))
>>> s
'0.9438182093746337'
>>> s=str(eval("math.sin(1.234)"))
>>> s
'0.9438182093746337'
>>>

Warning: it's to be used with care...


List of my other blog posts.