467,880 Members | 1,255 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,880 developers. It's quick & easy.

Extending Embedded Python and execute external script

What i need from my C application to do ?
1) To execute a python script from file.
2) The python script will call functions in my C application.

According to the answer from Ravi Teja (topic "C app and Python"), I
need to extend embedded python in my C application.

I saw several functions: PyRun_AnyFileExFlags, PyRun_SimpleFileExFlags,
PyRun_FileExFlags.

Questions:
1) Which one should i use in order to achieve what i need ?
2) I couldn't understand the differance betwwen the three ?
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 ?

Tnx,
Vertilka

Jan 4 '07 #1
  • viewed: 1574
Share:
1 Reply
"Vertilka" <ve******@gmail.comwrote:
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-simple...n-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>

Jan 4 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by satish | last post: by
2 posts views Thread by Anand K Rayudu | last post: by
1 post views Thread by Richard Townsend | last post: by
3 posts views Thread by Torsten Bronger | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.