Retrieve a variable from an embedded interpreter
Mike Johnson
afp_randjohnson at yahoo.com
Sun Feb 24 05:08:49 EST 2002
Hi all!
I have been searching through the documentation, and it doesn't
mention how to retrieve variables from the python interpreter. :-(
I'm trying to keep my embedding work as simple as possible. I'd like
to set a bunch of variables, run a script, and collect some values
after it has finished.
The following is sorta what I had in mind. This will work for my basic
needs, the only thing missing is to somehow retrieve the python
variable "a" and store it in my application's "sa".
------
void cb_script_execute ( void ) {
char *sa;
Py_Initialize ();
PyRun_SimpleString ( "a = \"hi\"" );
PyRun_SimpleString ( "print \"a=\" + a" );
/* PyArg_ParseTuple? */
/* printf ( "sa = %s\n", sa ); */
Py_Finalize ();
}
-----
Any help would be very appreciated! I've been searching through the
header files for the last couple of days, but I haven't found a
function dealing with this yet.
Thank you,
- Mike Johnson
More information about the Python-list
mailing list