Is it possible to execute Python code from C++ without writing to a file?

Anssi Saari as at sci.fi
Sat Apr 16 08:01:44 EDT 2011


Roger House <rhouse at sonic.net> writes:

> I tried PyRun_String, but I can't see how it can be used to return a
> tuple (the Py_file_input option always returns None).

There's an example of this at
http://stackoverflow.com/questions/3789881/create-and-call-python-function-from-string-via-c-api

The comments say this took quite a lot of investigation. I believe it
too, since it doesn't exactly leap out from the documentation... The
example returns only a single fixed integer, but changing it to return
a tuple shouldn't be a problem.



More information about the Python-list mailing list