hey everyone, does anyone know the python command that forces the interpreter to go interactive? the situation i'm talking about goes like this:

  • run script from command line
  • let all kinds of complicated nonsense execute
  • script runs the "go interactive" command
  • python dumps you in the interactive terminal and all your initialized work is there, freely available

i've tried hard to search for the term multiple times, but haven't been able to find it. i randomly stumbled upon it once, which is the only reason i know it exists. my search terms must be all off...


7 Years
Discussion Span
Last Post by chardson

I don't know about a "go interactive" command, but if you use pdb (python debugger) and set the pdb mark somewhere, it dumps you out into the interpreter with all your current workspace that the program has worked on so far. It's pretty simple to do, simply import pdb at the beginning of your program and then you mark the "go interactive" portion with the command pdb.set_trace() .

Take note, the pdb interface is kinda strange at first, but this documentation should help to qualm any trepidations you may encounter.


You could start idle like this in a terminal

idle -r complicated_nonsense.py

Another way is to run python with the PYTHONSTARTUP environment variable set to the file complicated_nonsense.py. It will then be executed when you start the interpreter.


heroic! it was in the man page and i missed it (but found it after you mentioned "idle -r"). using "python -i" will do the same thing.

i still think there's a command you can drop at the end of the script that does the same thing, but -i is just as good

thanks for pointing that out, i should really get familiar with the debugger in general

thanks for the replies, see you around

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.