I know how to import an hy
module into python. All I have to do is create a something.hy
file containing hy
code and then do the following ...
import hy
import something
something.func('args') # assumes there is an hy function called `func`
However, I haven't been able to figure out how to evaluate a string within python which contains hy
code. For example ...
hycode = '(print "it works!")'
hy.SOMEHOW_EVALUATE(hycode)
# I'd like this to cause the string `it works!` to print out.
Or this example ...
hycode = '(+ 39 3)'
result = hy.SOMEHOW_EVALUATE(hycode)
# I'd like result to now contain `42`
When using hy
within python, is there any way to evaluate strings in this manner?