python -i (interactive environment)

Joe JoeSalmeri at hotmail.com
Sun Mar 6 17:19:43 EST 2005


Funny you said that, because I didn't even bother trying it because I didn't 
think it would work either.  I figured that python did something internally 
when it saw the -i switch.  Looks like it just checks for it when it's done 
with your code.

One difference between the two methods that I see is that when you set 
PYTHONINSPECT you don't really have to do anything else and unless 
sys.exit() or raise SystemExit is used you will get the interactive prompt.

Using code.interact you would need to wrap everything in a try/except block 
and call code.interact from there, or you could invoke it whenever you 
wanted too.  This has the advantage that you can even trap SystemExit if you 
want too.

Thanks again to everyone!


"Michael Hoffman" <cam.ac.uk at mh391.invalid> wrote in message 
news:d0ftud$se6$2 at gemini.csx.cam.ac.uk...
> Joe wrote:
>
> Actually I would do that everyone else suggested for your use case. I 
> thought
> about trying this method but couldn't imagine that it would actually work!
> -- 
> Michael Hoffman 





More information about the Python-list mailing list