python -i (interactive environment)

Joe JoeSalmeri at
Sun Mar 6 20:19:45 CET 2005

Hi Pierre,

Thanks for the reply, but  I am not on Unix and it even if I was that 
solution it does not achieve the desired results.

I want the script to decide whether to fall back to the interactive prompt. 
You solution makes it ALWAYS fall back to the interactive prompt.

I want to do something like:

    # execute code
except MyExceptionOccurred, except_msg:
    # fall to interactive prompt.

In other words I want to have my program to determine whether the 
interactive prompt to be displayed or not.


"Pierre Barbier de Reuille" <pierre.barbier at> wrote in message 
news:422b49b5$0$23395$626a14ce at
> Very simple is you're on UNIX ...
> You juste have to put at the beginnin of your file :
> #!/usr/bin/python -i
> And it juste does what you want :)
> Pierre
> Joe a écrit :
>> When you run "python -i" after the script completes you 
>> left at the interactive command prompt.
>> Is there a way to have this occur from a running program?
>> In other words can I just run (NOT python -i 
>> and inside of I decide that I want to fall back to the 
>> interactive prompt?
>> I've searched and so far the only thing I've come up with is to use pdb, 
>> but that is not exactly the same as the interactive prompt.
>> Is there any way to do it that I have missed?
>> Thanks. 

More information about the Python-list mailing list