1 /* Example of embedding Python in another program */
11 /* Save a copy of argv0 */
14 /* Initialize the Python interpreter. Required. */
17 /* Define sys.argv. It is up to the application if you
18 want this; you can also let it undefined (since the Python
19 code is generally not a main program it has no business
20 touching sys.argv...) */
21 PySys_SetArgv(argc
, argv
);
23 /* Do some application specific code */
24 printf("Hello, brave new world\n\n");
26 /* Execute some Python statements (in module __main__) */
27 PyRun_SimpleString("import sys\n");
28 PyRun_SimpleString("print sys.builtin_module_names\n");
29 PyRun_SimpleString("print sys.argv\n");
31 /* Note that you can call any public function of the Python
32 interpreter here, e.g. call_object(). */
34 /* Some more application specific code */
35 printf("\nGoodbye, cruel world\n");
37 /* Exit, cleaning up the interpreter */
42 /* This function is called by the interpreter to get its own name */