1 /* Example of embedding Python in another program */
16 /* So the user can set argc/argv to something interesting */
17 argc
= ccommand(&argv
);
19 /* Save a copy of argv0 */
22 /* Initialize the Python interpreter. Required. */
29 /* Define sys.argv. It is up to the application if you
30 want this; you can also let it undefined (since the Python
31 code is generally not a main program it has no business
32 touching sys.argv...) */
33 PySys_SetArgv(argc
, argv
);
35 /* Do some application specific code */
36 printf("Hello, brave new world\n\n");
38 /* Execute some Python statements (in module __main__) */
39 PyRun_SimpleString("import sys\n");
40 PyRun_SimpleString("print sys.builtin_module_names\n");
41 PyRun_SimpleString("print sys.argv\n");
43 /* Note that you can call any public function of the Python
44 interpreter here, e.g. call_object(). */
46 /* Some more application specific code */
47 printf("\nGoodbye, cruel world\n");
49 printf("Type return or so-\n");
52 /* Exit, cleaning up the interpreter */
57 /* This function is called by the interpreter to get its own name */