Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Extending Embedded Python and execute external script

Reply
Thread Tools

Extending Embedded Python and execute external script

 
 
Vertilka
Guest
Posts: n/a
 
      01-04-2007
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

 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      01-04-2007
"Vertilka" <> 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-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>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
RE: How to execute a script from another script and other script doesnotdo busy wait. VYAS ASHISH M-NTB837 Python 2 01-07-2010 08:18 PM
How to Machine A python script execute Machine B python script? johnny Python 5 07-11-2007 01:03 PM
Re: Embedded and extending python 2.5: trouble with __main__ inPyRun_SimpleFileExFlags? Carl Douglas Python 0 03-05-2007 01:51 AM
Embedded and extending python 2.5: trouble with __main__ inPyRun_SimpleFileExFlags? Carl Douglas Python 0 02-19-2007 10:51 AM



Advertisments
 



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 48 49 50 51 52 53 54 55 56 57