Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
47 lines (42 loc) · 1.19 KB

File metadata and controls

47 lines (42 loc) · 1.19 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma hdrstop
#include <condefs.h>
#include <python.h>
USELIB("..\..\Components\py21.lib");
//---------------------------------------------------------------------------
using namespace Py;
//---------------------------------------------------------------------------
#pragma argsused
int ExecString( char * str )
{
PyObject *m, *d;
m = PyImport_AddModule("__main__");
if ( ! m )
return -1;
d = PyModule_GetDict(m);
PyObject * Result = PyRun_String(str, Py_file_input, d, d);
Py_DECREF(Result);
Py_FlushLine();
if ( PyErr_Occurred() )
PyErr_Print();
if ( Result )
return 0;
else
return -1;
}
int main(int argc, char **argv)
{
Py_SetProgramName(argv[0]);
// Init Python
Py_Initialize();
// Execute a script from a string
//if ( ExecString("for i in range(100):\n print 'Line #',i\n") )
if ( PyRun_SimpleString("for i in range(100):\n print 'Line #',i\n") )
fprintf(stderr, "Could not execute script !\n");
// Print some Python informations
fprintf(stderr, "Python %s on %s\n%s\n",
Py_GetVersion(), Py_GetPlatform(), Py_GetCopyright());
// Finalize Python
Py_Finalize();
// Terminate
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.