Re: embedding interactive python interpreter

2013-09-11 Thread Eric Frederich
Scott, Yes. As Mark Hammond suggested I took a look into the code/console modules. I wound up using InteractiveConsole from the code module. I'm sure my requirements are completely different from yours but I'll explain what I did anyway... I was working with a client/server architecture where I w

Re: embedding interactive python interpreter

2011-03-28 Thread Mark Hammond
On 28/03/2011 2:06 PM, Eric Frederich wrote: I'm not sure that I know how to run this function in such a way that it gives me an interactive session. I passed in stdin as the first parameter and NULL as the second and I'd get seg faults when running exit() or even imnport sys. I don't want to pa

Re: embedding interactive python interpreter

2011-03-27 Thread eryksun ()
On Sunday, March 27, 2011 11:06:47 PM UTC-4, Eric Frederich wrote: > I'm not sure that I know how to run this function in such a way that > it gives me an interactive session. > I passed in stdin as the first parameter and NULL as the second and > I'd get seg faults when running exit() or even imnp

Re: embedding interactive python interpreter

2011-03-27 Thread Eric Frederich
I'm not sure that I know how to run this function in such a way that it gives me an interactive session. I passed in stdin as the first parameter and NULL as the second and I'd get seg faults when running exit() or even imnport sys. I don't want to pass a file. I want to run some C code, start an

Re: embedding interactive python interpreter

2011-03-27 Thread Mark Hammond
On 28/03/2011 5:28 AM, Eric Frederich wrote: I'm not talking about the documentation for sys.exit() I'm talking about the documentation for Py_Main(int argc, char **argv) http://docs.python.org/c-api/veryhigh.html?highlight=py_main#Py_Main This C function never returns anything whether in the i

Re: embedding interactive python interpreter

2011-03-27 Thread eryksun ()
On Friday, March 25, 2011 12:02:16 PM UTC-4, Eric Frederich wrote: > > Is there something else I should call besides "exit()" from within the > interpreter? > Is there something other than Py_Main that I should be calling? Does PyRun_InteractiveLoop also have this problem? -- http://mail.python.o

Re: embedding interactive python interpreter

2011-03-27 Thread Eric Frederich
I'm not talking about the documentation for sys.exit() I'm talking about the documentation for Py_Main(int argc, char **argv) http://docs.python.org/c-api/veryhigh.html?highlight=py_main#Py_Main This C function never returns anything whether in the interpreter I type "exit(123)" or "sys.exit(123)

Re: embedding interactive python interpreter

2011-03-27 Thread Jerry Hill
On Sun, Mar 27, 2011 at 9:33 AM, Eric Frederich wrote: > This is behavior contradicts the documentation which says the value > passed to sys.exit will be returned from Py_Main. > Py_Main doesn't return anything, it just exits. > This is a bug. Are you sure that calling the builtin exit() function

Re: embedding interactive python interpreter

2011-03-27 Thread Eric Frederich
This is behavior contradicts the documentation which says the value passed to sys.exit will be returned from Py_Main. Py_Main doesn't return anything, it just exits. This is a bug. On Sun, Mar 27, 2011 at 3:10 AM, Mark Hammond wrote: > On 26/03/2011 4:37 AM, Eric Frederich wrote: > exit() will wi

Re: embedding interactive python interpreter

2011-03-27 Thread Mark Hammond
On 26/03/2011 4:37 AM, Eric Frederich wrote: So I found that if I type ctrl-d then the other lines will print. I think ctrl-d just causes sys.stdin to see EOF, so things just "fall out" as you desire. exit() will winf up causing the C exit() function after finalizing, hence the behaviour

Re: embedding interactive python interpreter

2011-03-25 Thread Eric Frederich
Added a fflush(stdout) after each printf and, as I expectedstill only the first 2 prints. On Fri, Mar 25, 2011 at 1:47 PM, MRAB wrote: > On 25/03/2011 17:37, Eric Frederich wrote: >> >> So I found that if I type ctrl-d then the other lines will print. >> >> It must be a bug then that the

Re: embedding interactive python interpreter

2011-03-25 Thread MRAB
On 25/03/2011 17:37, Eric Frederich wrote: So I found that if I type ctrl-d then the other lines will print. It must be a bug then that the exit() function doesn't do the same thing. The documentation says "The return value will be the integer passed to the sys.exit() function" but clearly n

Re: embedding interactive python interpreter

2011-03-25 Thread Eric Frederich
So I found that if I type ctrl-d then the other lines will print. It must be a bug then that the exit() function doesn't do the same thing. The documentation says "The return value will be the integer passed to the sys.exit() function" but clearly nothing is returned since the call to Py_Main

embedding interactive python interpreter

2011-03-25 Thread Eric Frederich
I am able to embed the interactive Python interpreter in my C program except that when the interpreter exits, my entire program exits. #include #include int main(int argc, char *argv[]){ printf("line %d\n", __LINE__); Py_Initialize(); printf("line %d\n", __LI