Extending Embedded Python and execute external script

Fredrik Lundh fredrik at pythonware.com
Thu Jan 4 08:02:59 EST 2007


"Vertilka" <vertilka at gmail.com> wrote:

> I saw several functions: PyRun_AnyFileExFlags, PyRun_SimpleFileExFlags,
> PyRun_FileExFlags.
>
> Questions:
> 1) Which one should i use in order to achieve what i need ?

PyRun_SimpleFile or PyRun_SimpleString should be good enough.  Using
SimpleString is more robust:

http://effbot.org/pyfaq/pyrun-simplefile-crashes-on-windows-but-not-on-unix-why.htm

and also lets you implement additional glue in Python code instead of in C/C++.

> 2) I couldn't understand the differance betwwen the three ?

AnyFile supports interactive devices, RunFile requires you to provide a custom
execution context.

> 3) What is the difference between the "FILE *fp" and "const char
> *filename" arguments of these functions. If i give a FILE*, why do i
> need to give the file name ?

Python needs the filename to be able to give meaningful error messages.

</F> 






More information about the Python-list mailing list