embedding interactive python interpreter
Mark Hammond
mhammond at skippinet.com.au
Sun Mar 27 03:10:47 EDT 2011
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 you see.
> In the mean time is there a way to redefine the exit function in
> Python to do the same behavior as "ctrl-d?"
You can just patch exit in builtins with your own function although I'm
not sure how you would terminate the builtin REPL - another alternative
may be to look into the code/console modules where you may be able to
arrange for more control over the REPL.
Cheers,
Mark
More information about the Python-list
mailing list