I have a Python script, and I want to execute it to a certain point, and then stop and leave the interpreter open so that I can see the variables that it defines, etc.
I know I can throw an exception, or I could call the debugger by running pdb.set_trace() and then stop the debugger that I am currently using.
... but is there a command that just stops the script as if it just reached the end? This would be equivalent to commenting out the rest of the script (but I would not want to do this), or putting an early return in a function.
It seems like something like this should exist, but I haven't found it yet.
Edit: some details of my use
I usually use regular Python consoles in Spyder. IPython looks pretty good, but (at least for the version I'm currently on, 2.2.5) some of the usual console functions do not work well in IPython (introspection, autocomplete). Most often, my code generates matplotlib numbers. In debug mode, these updates cannot be updated (as far as I know), so I need to completely exit the script, but not the interpreter). Another limit of the debugger is that I cannot execute loops in it: you can copy / paste the code for the loop into a regular console and execute it, but this will not work in the debugger (at least in my Spyder version).
source share