I need to evaluate (millions) of Python expressions, for example. (int(a) >> 8 == 4) and b
in my OCaml program. There is pycaml, but I could not get it to work.
So, I turned to another idea: directly control the input / output of the Python interpreter.
Ideally, I would like to intercept as the input / output of the interpreter itself. By sending to the interpreter a = 3 b = 5 a > b, I could get the result Falseas if I had done it using the keyboard.
>>> a = 3
>>> b = 5
>>> a > b
False
>>>
However, my code does not work as expected (while the same code worked for some interactive program)
let (readme, writeme) = Unix.open_process "python -u";;
let _ = output_string writeme "3 + 5\n" in
let _ = flush writeme in
let result = input_line readme in
print_endline result;;
3 + 5\n print 3\n, input_line.
?
, . ,
.