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. this page was rendered by a django application in 0.02s 2008-08-29 23:56:41.766604. hosted by webfaction.