jump into the interpreter in a script

Carl Friedrich Bolz cfbolz at gmx.de
Thu Feb 9 17:02:58 EST 2006


Brian Blais wrote:
> I was wondering if there is a way to, within a script, jump into the interpreter.
> What I mean is something like the "keyboard" command in Matlab, where the script
> pauses and you get an interpreter prompt, where you can look at variables, change
> their values, etc.  then when you exit the interpreter, the script continues from
> where it left off.  Is this possible in python?

Yes. The "code" module of the stdlib is what you want. put

import code
code.interact(local=locals())

into a point where you would like to have an interpreter prompt.

Cheers,

Carl Friedricch




More information about the Python-list mailing list