This is an old copy of the Python FAQ. The information here may be outdated.

How can I execute arbitrary Python statements from C?

The highest-level function to do this is PyRun_SimpleString which takes a single string argument to be executed in the context of the __main__ module and returns 0 for success and -1 when an exception occurred (including SyntaxError). If you want more control, use PyRun_String; see the source for PyRun_SimpleString in Python/pythonrun.c.

CATEGORY: extending


A Django site. rendered by a django application. hosted by webfaction.