Function python_cmd_string (o2scl)

O2scl : Function List

int o2scl::python_cmd_string(std::string cmd, std::string &result, bool err_on_fail = true, int nmax = 80, bool add_quotes = true)

Execute a python command and return the resulting string.

python_cmd_string("print(3+5)",result);

Alternatively, the code,

python_cmd_string("import sys; print(sys.prefix)",prefix,true,200);
if (prefix[prefix.length()-1]=='\n') {
prefix=prefix.substr(0,prefix.length()-1);
}
prints the current Python prefix.